https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100037
Bug ID: 100037 Summary: lookup doesn't find class template parameter in default member initializer of forward declared nested class template Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Issue title is a mouthful, but it's a very narrow case: template <bool C> using always_int = int; struct view { template <bool> struct iterator; template <bool Const> struct iterator { always_int<Const> inner = always_int<Const>(); }; }; This is rejected with: <source>:8:46: error: 'Const' was not declared in this scope 8 | always_int<Const> inner = always_int<Const>(); | ^~~~~ <source>:8:51: error: template argument 1 is invalid 8 | always_int<Const> inner = always_int<Const>(); | ^ This compiles if we also name the template parameter in the forward declaration. This fails only in the case of a nested class - if you change it to namespace view from struct view, the example compiles fine.