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] ... gcc.gnu.org_bugzilla at jfa dot knudsen.ovh via Gcc-bugs

Reply via email to