public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: asbrown@ati.com
To: gcc-gnats@gcc.gnu.org
Subject: preprocessor/3852: cpp: parantheses wrong in variable argument macros
Date: Fri, 27 Jul 2001 19:16:00 -0000	[thread overview]
Message-ID: <20010728020606.12740.qmail@sourceware.cygnus.com> (raw)

>Number:         3852
>Category:       preprocessor
>Synopsis:       cpp: parantheses wrong in variable argument macros
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 27 19:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     asbrown@ati.com
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
sparc-sun-solaris2.6
>Description:
I was using the variable macro arguments feature of cpp and I noticed some problems with the parantheses.  I haven't tried it on gcc 3.0.

Here is the source to test.c:

// here's something that works
#define TEST_GOOD(foo, args...) (foo, ## args)

// here's a variation that doesn't
#define TEST_BAD(foo, args...) (0, (foo), ## args)

// this is simpler and needs an argument to work
#define TEST_WORSE(args...) (0, ## args)

void main() {
  TEST_GOOD(0); // works
  TEST_BAD(0); // doesn't work
  TEST_WORSE(0); // works
  TEST_WORSE(); // doesn't work
}

If I run cpp test.c, I get 
# 1 "test.c"
 


 


 


void main() {
  ( 0  ) ;  
  (0, ( 0  ) ;  
  (0,0 ) ;  
   ) ;  
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-07-27 19:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-27 19:16 asbrown [this message]
2001-07-28  3:58 neil

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=20010728020606.12740.qmail@sourceware.cygnus.com \
    --to=asbrown@ati.com \
    --cc=gcc-gnats@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).