<< Back to previous view

[PCC-391] compile time assert is not constant Created: 20/Apr/12  Updated: 20/Apr/12

Status: Resolved
Project: pcc
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Iain Hibbert Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
Environment: NetBSD/i386


 Description   
The following code snipped, extracted from something generated by a CTASSERT macro and noted by
Toru Nishimura on the NetBSD current-users mailing list

struct foo {
    int a;
    int b[5];
};

int bar[ (__builtin_offsetof(struct foo, b[0]) == 4) ? 1 : -1 ]; /* not ok */

int baz[ (__builtin_offsetof(struct foo, b) == 4) ? 1 : -1 ]; /* ok */

fails compilation with

line 6: array size not constant

which is the bar declaration.. (btw it does work ok if bar is declared inside a function)



 Comments   
Comment by Iain Hibbert [ 20/Apr/12 02:18 PM ]
credit Toru Nishimura
Comment by Anders Magnusson [ 20/Apr/12 06:21 PM ]
Needed one more optimization; fixed now.
Generated at Tue Sep 02 13:34:16 CEST 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.