https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121691
Bug ID: 121691 Summary: -Wcomma-within-single-parentheses: New diagnostic for non-robust uses of the comma operator Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: foss+...@alejandro-colomar.es Target Milestone: --- The comma operator is easily confused with other uses of the comma token in C. Within parenthesized expressions, it can be confused as a function argument list separator, and if a function identifier is put before that parenthesized expression, it can change the meaning significantly, possibly without a diagnostic. Since the comma operator is very rarely useful, it would be good to write code that makes it explicit that it's a comma operator and cannot change meaning easily. For example, if I write a macro that uses the comma operator, I'd write it as #define foo ((expr1, expr2, expr3)) If I put a function identifier before that, it will not transform into a function call with 3 arguments, which makes it robust. I'd like a diagnostic that complains about (expr1, expr2, expr3), so that it forces me to add a second set of parentheses. The behavior of this proposed diagnostic would be: 0, 0, 1; // ok (0, 0, 1); // -Wcomma-within-single-parentheses ((0, 0, 1)); // ok