https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98286

            Bug ID: 98286
           Summary: g++ accepts 'void d(void) { typename foo; }' as valid
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: slyfox at gcc dot gnu.org
  Target Milestone: ---

Extracted from larger confusing boost example where g++ and clang++ disagree on
syntactic validity. Filing a small one:

    $ cat bug.cpp
    void d(void) { typename foo; }

$ g++-11.0.0 -c bug.cpp -Wall -Wextra
bug.cpp: In function 'void d()':
bug.cpp:1:25: warning: unused variable 'foo' [-Wunused-variable]
    1 | void d(void) { typename foo; }
      |                         ^~~
<success>

$ clang++ -c bug.cpp -Wall -Wextra
bug.cpp:1:25: error: expected a qualified name after 'typename'
void d(void) { typename foo; }
                        ^
bug.cpp:1:25: error: C++ requires a type specifier for all declarations
2 errors generated.
<failure>

It looks like g++ interpreted 'typename foo;' as 'int foo'.

Should the example compile?

Reply via email to