https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86598
Bug ID: 86598 Summary: Incorrect lexing of pp-numbers in C++11 due to hexfloat extension Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- g++ support C99 hexadecimal literals as an extension in its C++ modes. This is *almost* a conforming extension in C++98 mode, but it's far from being one in C++11 mode. For instance, in C++98: #define PREFIX(x) foo ## x void f() { int PREFIX(1p); int PREFIX(2p) = PREFIX(1p+5); } g++ rejects the above code: code2.cpp:1:19: error: pasting "foo" and "1p+5" does not give a valid preprocessing token #define PREFIX(x) foo ## x ^~~ code2.cpp:4:19: note: in expansion of macro 'PREFIX' int PREFIX(2p) = PREFIX(1p+5); ^~~~~~ code2.cpp: In function 'void f()': code2.cpp:1:19: error: 'foo' was not declared in this scope #define PREFIX(x) foo ## x ^~~ code2.cpp:4:19: note: in expansion of macro 'PREFIX' int PREFIX(2p) = PREFIX(1p+5); ^~~~~~ code2.cpp:1:19: note: suggested alternative: 'foo2p' #define PREFIX(x) foo ## x ^~~ code2.c.cpp:4:19: note: in expansion of macro 'PREFIX' int PREFIX(2p) = PREFIX(1p+5); ^~~~~~ In the rules of C++, "1p+5" is three tokens, not one. In C++11, this goes wrong in much less contrived situations: Units<Amp> operator"" _amp(unsigned long long d); int k = 4_amp+1; // incorrect error: no literal operator "" _amp+1 BTW, clang++ accepts the above code.