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

            Bug ID: 115377
           Summary: Invalid typename with non nested-name-specifier
                    accepted in specific contexts
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luigighiron at gmail dot com
  Target Milestone: ---

GCC will accept some invalid uses of typename, for example:

#include<iostream>
using V=int;
int main(){
    typename V=42;
    std::cout<<V<<'\n';
}

Here, it seems like GCC is interpreting the V as being both the type of the
thing declared and the thing that is being declared. Note that trying to give a
different name e.g. typename V v=42; causes GCC to give an error about
expecting a nested-name-specifier. Here are some more examples to demonstrate
the bug:

#include<iostream>
using V=int;
int main(){
    typename const V[2]=std::cout;
    typename(*V)[V?V,V:V](V){nullptr};
    typename random[main];
}

Reply via email to