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

            Bug ID: 94685
           Summary: Misleading error: array must be initialized with a
                    brace-enclosed initializer
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

using A = int[1];
  using AA = A[1];
  AA a1{A{1}};

ntconsarr.cc:3:9: error: array must be initialized with a brace-enclosed
initializer
    3 |   AA a1{A{1}};
      |         ^~~~

This clearly *is* a brace-enclosed initializer, so the error is not telling us
the real problem.

Clang is better:

$ clang++  ntconsarr.cc
ntconsarr.cc:3:9: error: cannot initialize an array element of type 'int' with
an rvalue of type 'A' (aka 'int [1]')
  AA a1{A{1}};
        ^~~~

EDG is different, but I'm not sure it's correct:

$ edg --c++14 ntconsarr.cc
"ntconsarr.cc", line 3: error: a value of type "int *" cannot be used to
          initialize an entity of type "int"
    AA a1{A{1}};
          ^

Reply via email to