[Bug c++/87713] New: single character underlined in an error message instead of the whole token
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 23 18:50:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87713
Bug ID: 87713
Summary: single character underlined in an error message
instead of the whole token
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Every now and then I notice a diagnostic where only a single character of a
token (identifier?) is underlined but up until now I haven't had luck
reproducing it (often times it involves macros). The ill-formed C++ test case
below shows one situation when this happens without macros. Note the
underlining in the second error.
$ cat t.C && gcc -S -Wall t.C
int i = sizeof ((int));
t.C:1:18: error: expected primary-expression before ‘int’
1 | int i = sizeof ((int));
| ^~~
t.C:1:18: error: expected ‘)’ before ‘int’
1 | int i = sizeof ((int));
| ~^~~
| )
t.C:1:23: error: expected ‘)’ before ‘;’ token
1 | int i = sizeof ((int));
| ~ ^
| )
Other C++ compilers as well as GCC's C front end handle this more gracefully.
They print just a single message along the lines of:
t.C:1:22: error: expected expression before ‘)’ token
More information about the Gcc-bugs
mailing list