[Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__.

2022-05-26 Thread gcc.gnu.org_bugzilla at jfa dot knudsen.ovh via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741

Bug ID: 105741
   Summary: Wrong preprocessor parameter substitution with
##__VA_ARGS__.
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
  Target Milestone: ---

This code :

#define CALL2(dummy, p1, ...) "dummy"=dummy, "p1"=p1, "va"=__VA_ARGS__

#define CALL(dummy, ...) CALL2(dummy, ##__VA_ARGS__)
#define CALL_WITHOPT(dummy, ...) CALL2(dummy __VA_OPT__(,) __VA_ARGS__)


#define CALL_ARGS "param1", "param2"

CALL("dum", "param1", "param2");
CALL_WITHOPT("dum", CALL_ARGS);
CALL("dum", CALL_ARGS);


preprocessed gives :

"dummy"="dum", "p1"="param1", "va"="param2";
"dummy"="dum", "p1"="param1", "va"="param2";
"dummy"="dum", "p1"="param1", "param2", "va"=;

We can see that, at the third line, parameter p1 = "param1", "param2" and
__VA_ARGS__ is empty.
It seems that CALL_ARGS expands to "param1", "param2" but is still only one
parameter in the variable list.

Is that the way it is supposed to be ?
Any workaround before it's fixed ?

[Bug c++/105741] Wrong preprocessor parameter substitution with ##__VA_ARGS__.

2022-05-26 Thread gcc.gnu.org_bugzilla at jfa dot knudsen.ovh via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741

--- Comment #1 from JFK  ---
Same problem with 10.2.0

[Bug c++/105741] Wrong preprocessor parameter substitution with ##__VA_ARGS__.

2022-05-26 Thread gcc.gnu.org_bugzilla at jfa dot knudsen.ovh via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741

--- Comment #3 from JFK  ---
Any idea about how to work around this without the use of VA_OPT ?