Issue Details (XML | Word | Printable)

Key: PCC-391
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Iain Hibbert
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

compile time assert is not constant

Created: 20/Apr/12 02:17 PM   Updated: 20/Apr/12 06:21 PM
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Environment: NetBSD/i386

 Description  « Hide
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)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Iain Hibbert added a comment - 20/Apr/12 02:18 PM
credit Toru Nishimura

Anders Magnusson added a comment - 20/Apr/12 06:21 PM
Needed one more optimization; fixed now.