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?".
This is fixed in 5.1 *** This bug has been marked as a duplicate of bug 13981 ***