On 24 April 2014 18:44, Matt Godbolt <matt@xxxxxxxxxxx> wrote: > > (__extension__ ({ register unsigned int __v, __x = (_ip); if > (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | > (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & > 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" > (__x)); __v; })) > > When invoked via ccache -Wextra and -std=c++1y this line causes the error: > error: address requested for '__x', which is declared 'register' > [-Werror=extra] Is this the actual output of GCC? GCC 4.9.0 should print column numbers and a caret pointing to the exact location in the macro expansion. >From the piece that you quote, the warning seems just bogus, so I think you should open a PR (http://gcc.gnu.org/bugs/) independently of the preprocessed vs. non-preprocessed issue. > However, when invoked directly, this error is somehow suppressed. Is > GCC aware of the fact this macro was defined in a system header and > thus suppresses the error? And therefore if it's > previously-preprocessed, this tagging is lost? Maybe. Could you try > $ g++-4.9.0 -Wextra -O -std=c++1y -c test.cc # compiles without error this -Wsystem-headers? Also, could you try building a testcase that doesn't use headers but it is not preprocessed? > $ g++-4.9.0 -Wextra -O -std=c++1y -c test.cc -E > test.preprocessed.cc > $ g++-4.9.0 -Wextra -O -std=c++1y -c test.preprocessed.cc > test.cc: In function 'uint32_t test(uint32_t)': > test.cc:4:134: warning: address requested for '__x', which is declared > 'register' [-Wextra] > uint32_t test(uint32_t x) { return htonl(x); } > ==== > > This only happens with std=c++1y, Wextra and -O (which macro-izes > htonl instead of making it an external function). It does not happen > with std=c++11. Do std=c++11 vs std=c++1y change anything in the preprocessed file? If not, the only way to understand what is going on is to put a break point at the warning point and figure out why it is (wrongly) warning. > Does anyone have a suggestion as to how to work around this issue? It > seems we can't disable just the address-of-register warning, only > Wextra itself (which removes other warnings we'd like). As workarounds, you could try #pragma GCC diagnostics ignored "Wextra" around that code. Or you could submit a patch to add an option -Waddress-of-register to control this warning. Cheers, Manuel.