Take:
int t;
int f = __builtin_constant_p(t) ? t : -1;
int h[__builtin_constant_p(t) ? t : 1];
--- CUT ---
This is accepted by the C front-end by rejected by the C++ front-end. I would
assume the built-in function __builtin_constant_p would cause it to be
considered as an integer constant expression but for some reason it is not.
The manual does say this about using it in static intializers:
You may also use __builtin_constant_p in initializers for static
data.
Which I had hoped it would cause it to be part of the constant integer
expression.
--
Summary: __builtin_constant_p(t) ? t : 1 is not considered a
constant integer expression
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38377