[Bug c/121691] -Wcomma-within-single-parentheses: New diagnostic for non-robust uses of the comma operator
foss+gcc@alejandro-colomar.es
gcc-bugzilla@gcc.gnu.org
Mon Dec 22 15:06:00 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121691
Alejandro Colomar <foss+gcc@alejandro-colomar.es> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #5 from Alejandro Colomar <foss+gcc@alejandro-colomar.es> ---
Actually, double commas are more dangerous than single. With single commas, if
at least one of the expressions is a void expression, it can't be accidentally
used as a parameter list. However, if there are double commas, it can be used
as a parameter list with one parameter.
alx@devuan:~/tmp$ cat comma.c
void f(...);
#define X(e) \
(( \
(void)0, \
(e) \
))
#define Y(e) \
( \
(void)0, \
(e) \
)
int
main(void)
{
f X(1);
f Y(1);
}
alx@devuan:~/tmp$ gcc -Wall -Wextra comma.c
comma.c: In function ‘main’:
comma.c:11:30: error: invalid use of void expression
11 | _Generic(e, default: (void)0), \
| ^~~~~~~
comma.c:19:11: note: in expansion of macro ‘Y’
19 | f Y(1);
| ^
More information about the Gcc-bugs
mailing list