This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/38377] New: __builtin_constant_p(t) ? t : 1 is not considered a constant integer expression
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2008 21:58:50 -0000
- Subject: [Bug c++/38377] New: __builtin_constant_p(t) ? t : 1 is not considered a constant integer expression
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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