[Bug c++/54021] [c++0x] __builtin_constant_p should be constexpr

david at doublewise dot net gcc-bugzilla@gcc.gnu.org
Sat Sep 8 21:36:00 GMT 2012


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

David Stone <david at doublewise dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david at doublewise dot net

--- Comment #5 from David Stone <david at doublewise dot net> 2012-09-08 21:36:10 UTC ---
I'm running into some issues with this bug, and it's much broader than the test
cases suggest. On gcc 4.7.0, this is what happens:

int main() {
    int x = 0;
    // This assigns false to a:
    bool const a = __builtin_constant_p(x);
    // This assigns true to b:
    bool const b = __builtin_constant_p(__builtin_constant_p(x));
    // This causes "error: the value of 'x' is not usable in a constant
expression"
    constexpr bool c = __builtin_constant_p(x);
}



More information about the Gcc-bugs mailing list