[Bug c++/94926] New: [9 regression] invalid use of incomplete type not recogniced for static self reference of templated struct

max.kanold@nu-cost.com gcc-bugzilla@gcc.gnu.org
Sat May 2 20:26:43 GMT 2020


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

            Bug ID: 94926
           Summary: [9 regression] invalid use of incomplete type not
                    recogniced for static self reference of templated
                    struct
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: max.kanold@nu-cost.com
  Target Milestone: ---

The following illegal code, correctly rejected by GCC 8.3, compiles from GCC
9.1 onwards (only checking compiler version available on Compiler Explorer),
see https://godbolt.org/z/rfD8sF

================================
template<typename>
struct A {
    static auto self_reference = A{};
};

int main() {
    A<void>{};
}
================================

When specifying the injected class name or removing all templates, the code is
rejected as expected.


More information about the Gcc-bugs mailing list