This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65845] typeid doesn't work consistently on pure virtual classes
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 22 Apr 2015 13:20:51 +0000
- Subject: [Bug c++/65845] typeid doesn't work consistently on pure virtual classes
- Auto-submitted: auto-generated
- References: <bug-65845-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65845
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The expression typeid(Interface()) is the type of a function that returns
Interface, but such a function cannot exist because the type is abstract.
I don't know why typeid(Vector<Interface>) needs to instantiate the default
argument.
The output from trunk is:
t.cc: In function âint main()â:
t.cc:20:20: error: âtype nameâ declared as function returning an abstract class
type
typeid(Interface()).name(); //GCC 4.9.2 and VS2013: doesn't compile
^
t.cc: In instantiation of âclass Vector<Interface>â:
t.cc:38:1: required from here
t.cc:11:8: error: cannot allocate an object of abstract type âInterfaceâ
void resize(unsigned n, T val = T()); //C++03 style resize
^
t.cc:3:7: note: because the following virtual functions are pure within
âInterfaceâ:
class Interface {
^
t.cc:5:15: note: virtual int Interface::size() const
virtual int size() const = 0;
^