https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96068
Bug ID: 96068 Summary: Extra semicolon outside of a function should be allowed after c++11? Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: haoxintu at gmail dot com Target Milestone: --- Hi, all. As the summary, extra ";" should be allowed in GCC after -std=c++11 and shouldn't give a diagnostic message about it? I know this is forbidden in c++98. For example, $cat test.cc void foo() { }; $g++ -c -std=c++98 -pedantic-errors test.cc test.cc:1:16: error: extra ';' [-Wpedantic] 1 | void foo () { }; | ^ $g++ -c -std=c++11 -pedantic-errors test.cc test.cc:1:16: error: extra ';' [-Wpedantic] 1 | void foo () { }; | ^ While in Clang, this is accepted in c++11 or later. $clang++ -c -std=c++98 -pedantic-errors test.cc test.cc:1:15: error: extra ';' outside of a function is a C++11 extension [-Werror,-Wc++11-extra-semi] void foo() { }; ^ 1 error generated. There is also a related bug report in llvm: https://bugs.llvm.org/show_bug.cgi?id=46288 They suggested that "If GCC rejects this under -pedantic-errors in C++11 or later, I think that's a GCC bug." I try to find a similar bug report in GCC but failed. Did I miss something? Thank you very much.