[Bug c++/85662] [8/9 Regression] "error: non-constant condition for static assertion" from __builtin_offsetof in C++
roland at gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu May 31 00:10:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85662
roland at gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #9 from roland at gnu dot org ---
Both my original test case and Jakub's smaller case do hit the bug in gcc 7.
I just tested the current gcc-7-branch: commit
c66c7f7b6f41118cef03ece0c367554eb38c3d65
On x86_64-linux-gnu:
$ ../../gcc/configure --enable-languages=c,c++,lto
$ make all-gcc
$ ./gcc/xgcc -Bgcc/ -O2 -S bar.cc
bar.cc:3:1: error: non-constant condition for static assertion
static_assert (__builtin_offsetof (T, f.x[31 - 1]) == __builtin_offsetof (T,
f.x[30]), "");
^~~~~~~~~~~~~
bar.cc:3:1: error: value ‘8’ of type ‘T*’ is not a constant expression
[Exit 1]
$ cat bar.cc
struct S { unsigned long x[31]; };
struct T { bool b; S f; };
static_assert (__builtin_offsetof (T, f.x[31 - 1]) == __builtin_offsetof (T,
f.x[30]), "");
$
More information about the Gcc-bugs
mailing list