public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__.
@ 2022-05-26 14:28 gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:29 ` [Bug c++/105741] " gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gcc.gnu.org_bugzilla at jfa dot knudsen.ovh @ 2022-05-26 14:28 UTC (permalink / raw)
To: 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 ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105741] Wrong preprocessor parameter substitution with ##__VA_ARGS__.
2022-05-26 14:28 [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__ gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
@ 2022-05-26 14:29 ` gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:48 ` jakub at gcc dot gnu.org
2022-05-26 14:51 ` gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2 siblings, 0 replies; 4+ messages in thread
From: gcc.gnu.org_bugzilla at jfa dot knudsen.ovh @ 2022-05-26 14:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741
--- Comment #1 from JFK <gcc.gnu.org_bugzilla at jfa dot knudsen.ovh> ---
Same problem with 10.2.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105741] Wrong preprocessor parameter substitution with ##__VA_ARGS__.
2022-05-26 14:28 [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__ gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:29 ` [Bug c++/105741] " gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
@ 2022-05-26 14:48 ` jakub at gcc dot gnu.org
2022-05-26 14:51 ` gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-26 14:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Even gcc 3.2 behaves this way. It is a GNU extension, so there is no standard
that would cover this except for GCC documentation (and implementation). And
clang behaves the same.
So I think it would only cause harm to change this.
Especially when the extension is there only for backwards compatibility, new
code should use __VA_OPT__ which is standard.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/105741] Wrong preprocessor parameter substitution with ##__VA_ARGS__.
2022-05-26 14:28 [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__ gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:29 ` [Bug c++/105741] " gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:48 ` jakub at gcc dot gnu.org
@ 2022-05-26 14:51 ` gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2 siblings, 0 replies; 4+ messages in thread
From: gcc.gnu.org_bugzilla at jfa dot knudsen.ovh @ 2022-05-26 14:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105741
--- Comment #3 from JFK <gcc.gnu.org_bugzilla at jfa dot knudsen.ovh> ---
Any idea about how to work around this without the use of VA_OPT ?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-26 14:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 14:28 [Bug c++/105741] New: Wrong preprocessor parameter substitution with ##__VA_ARGS__ gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:29 ` [Bug c++/105741] " gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
2022-05-26 14:48 ` jakub at gcc dot gnu.org
2022-05-26 14:51 ` gcc.gnu.org_bugzilla at jfa dot knudsen.ovh
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).