C++ Logo

std-discussion

Advanced search

Re: Interpretation of __VA_OPT__ construct

From: Tam S. B. <cpplearner_at_[hidden]>
Date: Fri, 1 Nov 2019 07:29:06 +0000
I agree that TRY_VA_OPT(NO_DATA) should expand to 1. That is, GCC does not correctly implement P1042R1 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1042r1.html ).

________________________________________
From: Std-Discussion <std-discussion-bounces_at_[hidden]> on behalf of Edward Diener via Std-Discussion <std-discussion_at_[hidden]>
Sent: Friday, November 1, 2019 7:12:39 AM
To: std-discussion_at_[hidden]
Cc: Edward Diener
Subject: [std-discussion] Interpretation of __VA_OPT__ construct

My original message became garbled somehow with a strange symbol instead
of a space so I will try again.

Given:

#define NO_DATA
#define TRY_VA_OPT(...) __VA_OPT__ (0) 1

granted that TRY_VA_OPT() expands to 1, what does TRY_VA_OPT(NO_DATA)
expand to ?

I would have thought that it also expands to 1 but gcc-9.2 in C++20 mode
expands it to 0 1 while clang-9.0 in C++20 expands it to 1. In trying to
interpret 15.6.1 paragraph 3 of n4835 it seems to me that the
determination of whether or not the __VA_OPT__ construct expands to a
single placemarker token or its pp-tokens should be made based on the
variadic parameter argument(s) after they are fully macro replaced,
since all occurrences of __VA_ARGS__ in the replacement list occur after
the variadic parameter argument(s) are fully macro replaced, just like
any other parameter in the replacement list.

What is the correct interpretation of how this should work ?
--
Std-Discussion mailing list
Std-Discussion_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2019-11-01 02:31:25