public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98042] New: error diagnostic for unmatched parentheses could be improved
@ 2020-11-28 13:32 tangyixuan at mail dot dlut.edu.cn
2021-11-28 0:46 ` [Bug c++/98042] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: tangyixuan at mail dot dlut.edu.cn @ 2020-11-28 13:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98042
Bug ID: 98042
Summary: error diagnostic for unmatched parentheses could be
improved
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tangyixuan at mail dot dlut.edu.cn
Target Milestone: ---
Hi, the following code is invalid due to the missing of ')' after '*' in Line
4. GCC reports an error which is difficult to understand. Maybe it could be
improved I guess?
$ cat s.cpp
int main (void)
{
double foo[4096];
((char *double(foo))[(sizeof(foo)-1)] = '\0'; // ')' instead of 'double'
return 0;
}
$ g++ -c s.cpp
s.cpp: In function ‘int main()’:
s.cpp:4:5: error: expected primary-expression before ‘char’
4 | ((char *double(foo))[(sizeof(foo)-1)] = '\0';
| ^~~~
s.cpp:4:5: error: expected ‘)’ before ‘char’
4 | ((char *double(foo))[(sizeof(foo)-1)] = '\0';
| ~^~~~
| )
s.cpp:4:47: error: expected ‘)’ before ‘;’ token
4 | ((char *double(foo))[(sizeof(foo)-1)] = '\0';
| ~ ^
| )
$ clang++ -c s.cpp
s.cpp:4:11: error: expected ')'
((char *double(foo))[(sizeof(foo)-1)] = '\0';
^
s.cpp:4:4: note: to match this '('
((char *double(foo))[(sizeof(foo)-1)] = '\0';
^
$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-20201122/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-20201122/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-11-20201122/configure --prefix=/usr/local/gcc-20201122
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201122 (experimental) (GCC)
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/98042] error diagnostic for unmatched parentheses could be improved
2020-11-28 13:32 [Bug c++/98042] New: error diagnostic for unmatched parentheses could be improved tangyixuan at mail dot dlut.edu.cn
@ 2021-11-28 0:46 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-28 0:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98042
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-28
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, the C front-end does a better job:
<source>:4:11: error: expected ')' before 'double'
4 | ((char *double(foo))[(sizeof(foo)-1)] = '\0'; // ')' instead of
'double'
| ~ ^~~~~~
| )
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-28 0:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-28 13:32 [Bug c++/98042] New: error diagnostic for unmatched parentheses could be improved tangyixuan at mail dot dlut.edu.cn
2021-11-28 0:46 ` [Bug c++/98042] " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).