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

            Bug ID: 70156
           Summary: incorrect "incomplete type" error initializing a
                    static const data member
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The two definitions of the data members of class C in the program below are
rejected as a required.  However, the text of only the second diagnostic is
correct.  The text of the first diagnostic is not since the type A<0> is
complete at the point it's used.

$ cat v.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc
-B/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ v.c
template <int> struct A { int i; };
struct B { int i; };
struct C {
    static const A<0> a = { 0 };
    static const B b = { 1 };
};
v.c:4:31: error: in-class initialization of static data member ‘const A<0>
C::a’ of incomplete type
     static const A<0> a = { 0 };
                               ^
v.c:5:28: error: ‘constexpr’ needed for in-class initialization of static data
member ‘const B C::b’ of non-integral type [-fpermissive]
     static const B b = { 1 };
                            ^

Reply via email to