[Bug c++/86565] New: failing to instantiate all of a local class

zhonghao at pku dot org.cn gcc-bugzilla@gcc.gnu.org
Wed Jul 18 06:23:00 GMT 2018


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

            Bug ID: 86565
           Summary: failing to instantiate all of a local class
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The code is as follow:

template<typename T> void f() {
 struct S { void g(int n = T::error) noexcept(T::error); };
}
template void f<int>();

g++ accepts it, but clang++ rejects it:

code0.cpp:2:28: error: type 'int' cannot be used prior to '::' because it has
      no members
 struct S { void g(int n = T::error) noexcept(T::error); };
                           ^
code0.cpp:2:9: note: in instantiation of member class 'S' requested here
 struct S { void g(int n = T::error) noexcept(T::error); };
        ^
code0.cpp:4:15: note: in instantiation of function template specialization
      'f<int>' requested here
template void f<int>();
              ^
code0.cpp:2:47: error: type 'int' cannot be used prior to '::' because it has
      no members
 struct S { void g(int n = T::error) noexcept(T::error); };
                                              ^
2 errors generated.


g++ should reject this, because instantiating a function is supposed to
instantiate everything within the function, even pieces of a local class.

(Incidentally, failing to do this can lead to the "decl not instantiated in
this scope" assertion.)


More information about the Gcc-bugs mailing list