[Bug preprocessor/33877] Request for __VA_ARGC__
foss+gcc@alejandro-colomar.es
gcc-bugzilla@gcc.gnu.org
Tue Aug 26 21:19:44 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33877
--- Comment #11 from Alejandro Colomar <foss+gcc@alejandro-colomar.es> ---
Moreover, __VA_OPT__ is not even self-consistent.
alx@debian:~/tmp$ cat vo.c | nl -ba
1 #define foo(...) __LINE__: foo: __VA_OPT__(nonzero args:
__VA_ARGS__)
2 #define bar(a, ...) __LINE__: bar: __VA_OPT__(nonzero args:
__VA_ARGS__)
3
4 foo()
5 foo(x)
6 foo(,)
7
8 bar(a)
9 bar(a,)
10 bar(a,b)
11 bar(a,b,)
12
13 #define f(...) __LINE__: f:, ## __VA_ARGS__
14 #define b(a, ...) __LINE__: b:, ## __VA_ARGS__
15
16 f()
17 f(x)
18 f(,)
19
20 b(a)
21 b(a,)
22 b(a,b)
23 b(a,b,)
alx@debian:~/tmp$ gcc -E vo.c | grep -v ^# | uniq
4: foo:
5: foo: nonzero args: x
6: foo: nonzero args: ,
8: bar:
9: bar:
10: bar: nonzero args: b
11: bar: nonzero args: b,
16: f:
17: f:,x
18: f:,,
20: b:
21: b:,
22: b:,b
23: b:,b,
Compare lines 9 and 11. It respects the trailing empty argument if there's at
least two variadic arguments, but if there's only one variadic argument and
it's empty, it's somehow a second-class empty argument, and it's ignored.
That's totally bogus. __VA_ARGC__ should be modeled after GNU C's ##
__VA_ARGS__, and not the standard.
More information about the Gcc-bugs
mailing list