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

            Bug ID: 90540
           Summary: Improve diagnostic for forming array of abstract class
                    type
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

struct ABC {
  virtual void f() = 0;
};
template<typename T> struct X { };
X<ABC[]> x;

Gives the error:

abc.cc:5:6: error: array of abstract class type 'ABC'
X<ABC[]> x;
     ^
abc.cc:2:16: note: unimplemented pure virtual method 'f' in 'ABC'
  virtual void f() = 0;
               ^
1 error generated.

This isn't very helpful, because there's no attempt to allocate any object of
type ABC. It would be better to say something like arrays of abstract class
types are not valid types (although I don't see where the standard says you
can't even refer to them in this context).

Clang says:

abc.cc:5:6: error: array of abstract class type 'ABC'
X<ABC[]> x;
     ^
abc.cc:2:16: note: unimplemented pure virtual method 'f' in 'ABC'
  virtual void f() = 0;
               ^
1 error generated.

Which is slightly better, but it doesn't actually say what's *wrong* with an
array of abstract class type.

EDG wins here:

"abc.cc", line 5: error: array of abstract class "ABC" is not allowed:
            function "ABC::f" is a pure virtual function
  X<ABC[]> x;
       ^

1 error detected in the compilation of "abc.cc".

Reply via email to