<< 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

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)

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 Sun Oct 22 01:06:28 CEST 2017 using JIRA Enterprise Edition, Version: 3.13.1-#333.