public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sebor at roguewave dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/12607] New: preprocessor fails to diagnose an undefined ## result
Date: Mon, 13 Oct 2003 23:48:00 -0000	[thread overview]
Message-ID: <20031013234821.12607.sebor@roguewave.com> (raw)

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;


             reply	other threads:[~2003-10-13 23:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-13 23:48 sebor at roguewave dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031013234821.12607.sebor@roguewave.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).