[Bug preprocessor/12607] New: preprocessor fails to diagnose an undefined ## result
sebor at roguewave dot com
gcc-bugzilla@gcc.gnu.org
Mon Oct 13 23:48:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12607
Summary: preprocessor fails to diagnose an undefined ## result
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
CC: gcc-bugs at gcc dot gnu dot org
The preprocessor issues an error for the case marked #1 in the program below but
fails to diagnose a similar construct marked #2. In neither instance the result
of the ## operator yields a single valid pp-token. For consistency I suggest
that gcc diagnose both cases.
Additionally, to make porting to gcc from more permissive compilers (no other
compiler gives an error for this by default) easier, I suggest that these cases
be only flagged as warnings when -Wall is used (and silently accepted otherwise)
and turned into hard errors only when -Werror is used.
Thanks
Martin
$ catnc t.cpp && gcc -E t.cpp
/* 1 */ #define CAT(a, b) a ## b
/* 2 */
/* 3 */ struct S { enum { ab }; } s;
/* 4 */
/* 5 */ int i = CAT (1+, 2); // #1
/* 6 */ int j = CAT (s.a, b); // #2
# 1 "t.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "t.cpp"
struct S { enum { ab }; } s;
t.cpp:5:19: pasting "+" and "2" does not give a valid preprocessing token
int i = 1 + 2;
int j = s.ab;
More information about the Gcc-bugs
mailing list