[Bug c++/66161] New: gcc silent about type incompleteness in error message

tromey at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri May 15 14:32:00 GMT 2015


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

            Bug ID: 66161
           Summary: gcc silent about type incompleteness in error message
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org
  Target Milestone: ---

This source is distilled from a more complicated real-world
case that arose in https://bugzilla.mozilla.org/show_bug.cgi?id=1165184

class Base { };

class Incomplete; // : public Base

template<typename T>
Base* blah_cast(T *arg) { return arg; }

Base* function(Incomplete *arg)
{
  return blah_cast(arg);
}


Compiling this yields:

pokyo. g++ -c s.cc
s.cc: In instantiation of ‘Base* blah_cast(T*) [with T = Incomplete]’:
s.cc:10:23:   required from here
s.cc:6:34: error: cannot convert ‘Incomplete*’ to ‘Base*’ in return
 Base* blah_cast(T *arg) { return arg; }
                                  ^


In this case it is obvious that Incomplete is an incomplete type.
However, in the real-world code this is far from obvious.

I think it would be handy if gcc printed something like
"note: type 'Incomplete' is incomplete at this point; missing include?".


More information about the Gcc-bugs mailing list