From: Segher Boessenkool <segher@kernel.crashing.org>
To: Edward Diener <eldlistmailingz@tropicsoft.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Possible __VA_OPT__ bug
Date: Thu, 31 Oct 2019 20:21:00 -0000 [thread overview]
Message-ID: <20191031202058.GZ28442@gate.crashing.org> (raw)
In-Reply-To: <qpfad0$1rn$1@blaine.gmane.org>
On Thu, Oct 31, 2019 at 02:50:07PM -0400, Edward Diener wrote:
> On 10/31/2019 1:14 PM, Segher Boessenkool wrote:
> >On Thu, Oct 31, 2019 at 12:42:54PM -0400, Edward Diener wrote:
> >>Given:
> >>
> >>#define NO_DATA
> >>#define TRY_VA_OPT(...) __VA_OPT__ (0) 1
> >>
> >>TRY_VA_OPT() -> expands to 1 as expected
> >>TRY_VA_OPT(NO_DATA) -> expands to 0 1 which is not expected
> >>
> >>when compiled with gcc-9.2 with -std=c++2a.
> >
> >Why is that not expected? The variadic macro TRY_VA_OPT does get tokens
> >in its variable argument (namely, NO_DATA), so __VA_OPT__ expands to its
> >argument (which is 0).
> >
> >https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
>
> The wording of 15.6.1 paragraph 3 is confusing to me. I had thought that
> the arguments to the variadic ... parameter were completely macro
> expanded before considering whether the __VA_OPT__ ( pp-tokens ) would
> expand to 'pp_tokens' or a single placemarker token. Evidently you are
> saying that the correct interpretation with the __VA_OPT__ construct is
> that the variadic ... arguments are not macro expanded before
> consideration of the __VA_OPT__ construct processing . This seems to me
> very odd because the arguments to the variadic ... parameter are always
> completely macro expanded before being replaced by any __VA_ARGS__
> parameter in the replacement list. I wonder why the C++ standard
> committee decided to treat __VA_OPT__ differently from __VA_ARGS__ in
> this regard ?
I don't know. I don't know if the GCC implementation is correct, either.
Segher
next prev parent reply other threads:[~2019-10-31 20:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-31 16:43 Edward Diener
2019-10-31 17:15 ` Segher Boessenkool
2019-10-31 18:50 ` Edward Diener
2019-10-31 20:21 ` Segher Boessenkool [this message]
2019-10-31 20:28 ` Edward Diener
2019-10-31 21:28 ` Jędrzej Dudkiewicz
2019-10-31 21:31 ` Jędrzej Dudkiewicz
2019-11-01 14:39 ` Edward Diener
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=20191031202058.GZ28442@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=eldlistmailingz@tropicsoft.com \
--cc=gcc-help@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).