public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "haoxintu at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96077] New: GCC accepts ill-legal local enum definition Date: Mon, 06 Jul 2020 12:31:26 +0000 [thread overview] Message-ID: <bug-96077-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96077 Bug ID: 96077 Summary: GCC accepts ill-legal local enum definition Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi, all. This code, test.cc, has a grammar issue in "missing ')'", but GCC accepts it well. $cat test.cc enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject int main () { enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept return 0; } $g++ test.cc test.cc:1:35: error: expected ‘)’ before ‘}’ token 1 | enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject | ~ ^~ | ) GCC only rejects line 1 but accepts line 3. While in Clang $clang++ test.cc test.cc:1:36: error: expected ')' enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject ^ test.cc:1:28: note: to match this '(' enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 } g_e; //reject ^ test.cc:3:63: error: expected ')' enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept ^ test.cc:3:32: note: to match this '(' enum { a = ( 1 ) ? ( 2 ) : ( 2 + 1 /* missing ")" here */ } l_e; //accept ^ 2 errors generated. $g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/home/haoxin/corpus-compilers/gcc-trunk/gcc-master/build/ --enable-languages=c,c++ CC=gcc CXX=g++ Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20200630 (experimental) (GCC)
next reply other threads:[~2020-07-06 12:31 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-06 12:31 haoxintu at gmail dot com [this message] 2020-07-06 13:44 ` [Bug c++/96077] " redi at gcc dot gnu.org 2020-07-06 13:50 ` haoxintu at gmail dot com 2020-07-08 20:22 ` mpolacek at gcc dot gnu.org 2020-07-09 20:35 ` mpolacek at gcc dot gnu.org 2020-07-09 21:40 ` mpolacek at gcc dot gnu.org 2020-07-10 15:48 ` mpolacek at gcc dot gnu.org 2020-07-13 15:16 ` cvs-commit at gcc dot gnu.org 2020-07-13 15:19 ` cvs-commit at gcc dot gnu.org 2020-07-13 15:19 ` mpolacek at gcc dot gnu.org 2020-07-13 15:19 ` mpolacek at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-96077-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).