public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/12607] New: preprocessor fails to diagnose an undefined ## result
@ 2003-10-13 23:48 sebor at roguewave dot com
  2003-10-14  0:08 ` [Bug preprocessor/12607] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: sebor at roguewave dot com @ 2003-10-13 23:48 UTC (permalink / raw)
  To: gcc-bugs

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;


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-09-28  4:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-13 23:48 [Bug preprocessor/12607] New: preprocessor fails to diagnose an undefined ## result sebor at roguewave dot com
2003-10-14  0:08 ` [Bug preprocessor/12607] " pinskia at gcc dot gnu dot org
2003-10-14  0:29 ` sebor at roguewave dot com
2003-10-14  0:41 ` pinskia at gcc dot gnu dot org
2003-10-14  1:00 ` sebor at roguewave dot com
2003-10-14  5:50   ` Neil Booth
2003-10-14  5:50 ` neil at daikokuya dot co dot uk
2003-10-14 15:30 ` sebor at roguewave dot com
2003-10-14 20:30   ` Neil Booth
2003-10-14 20:30 ` neil at daikokuya dot co dot uk
2003-10-14 20:57 ` sebor at roguewave dot com
2003-10-16 16:18 ` sebor at roguewave dot com
2005-09-28  4:11 ` pinskia at gcc dot gnu dot org
2005-09-28  4:13 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).