https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120657
Bug ID: 120657 Summary: Improve diagnostic for conditional operators that create the invalid type restrict void Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- Here are two programs that both incorrectly use a conditional operator, and their error messages generated by GCC (<source> is the name of the file on godbolt). Program 1: int main(void){ void*p=0; int*restrict*q=0; typedef typeof(1?p:q)T; } Error 1: <source>:4:5: error: invalid use of 'restrict' 4 | typedef typeof(1?p:q)T; | ^~~~~~~ Program 2: int main(void){ float*p=0; int*restrict*q=0; typedef typeof(1?p:q)T; } Error 2: <source>:4:23: error: pointer type mismatch in conditional expression [-Wincompatible-pointer-types] 4 | typedef typeof(1?p:q)T; | ^ <source>:4:22: note: first expression has type 'float *' 4 | typedef typeof(1?p:q)T; | ^ <source>:4:24: note: second expression has type 'int * restrict*' 4 | typedef typeof(1?p:q)T; | ^ In error 2 the colon of the conditional expression is pointed to, and the type of the operands are pointed out to help clarify the issue. However, in error 1 it just says restrict is used incorrectly and points to the first token on the same line as the closing parenthesis. I think it is worth improving the error message of program 1 to indicate that the conditional expression is causing the error.