This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/65845] typeid doesn't work consistently on pure virtual classes


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;
               ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]