[Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions

austern at apple dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 25 20:33:00 GMT 2005


The following test case is accepted by 3.3 (both C and C++) and by 4.0 C, but not by 4.0 C++.
#define FOO(x) (__builtin_constant_p(x) ? 1 : 2)

int foo(int n) {
  switch(n) {
  case FOO(3):
    return 1;
  default:
    return 2;
  }
}

Was this change intentional?  Even if it was, the C/C++ incompatibility is unfortunate.  This sort of 
construct is likely to appear in headers used by both languages.  (And we can't very well point to 
language standards in deciding whether __builtin_constant_p should be considered a constant-
expression, since it's a GNU extension.)

-- 
           Summary: g++ no longer accepts __builtin_constant_p in constant-
                    expressions
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: austern at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.7.0
  GCC host triplet: powerpc-apple-darwin7.7.0
GCC target triplet: powerpc-apple-darwin7.7.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628



More information about the Gcc-bugs mailing list