http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53091
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-23
18:38:29 UTC ---
The bug reporting guidelines ask for source code, not a URL.
Here's the code from the URL
#include <stdio.h>
const int SDL_HAT_UP = 0x01;
const int SDL_HAT_RIGHT = 0x02;
const int SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT | SDL_HAT_UP);
int main(int argc, char **argv)
{
printf("%x\n",SDL_HAT_RIGHTUP);
return 0;
}
I think GCC is correct, the code is valid C++ but not valid C.
In C the initializer for a global variable must be a constant expression ("All
the expressions in an initializer for an object that has static storage
duration shall be constant expressions or string literals.") and (SDL_HAT_RIGHT
| SDL_HAT_UP) is not a constant expression.
http://c-faq.com/ansi/constasconst.html
I believe Clang is allowed to accept the code because the C standard also says
implementations may accept other forms of constant expression.