From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 271F63857C48; Thu, 26 May 2022 14:28:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 271F63857C48 From: "gcc.gnu.org_bugzilla at jfa dot knudsen.ovh" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__. Date: Thu, 26 May 2022 14:28:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc.gnu.org_bugzilla at jfa dot knudsen.ovh X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2022 14:28:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105741 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"=3Ddummy, "p1"=3Dp1, "va"=3D__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"=3D"dum", "p1"=3D"param1", "va"=3D"param2"; "dummy"=3D"dum", "p1"=3D"param1", "va"=3D"param2"; "dummy"=3D"dum", "p1"=3D"param1", "param2", "va"=3D; We can see that, at the third line, parameter p1 =3D "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 ?=