Since abstract classes cannot be instantiated without being derived, any
classes inherited virtually in an abstract class cannot have their
constructor called by the abstract class constuctor hence the abstract
class constructor must not reference the constructor of any virtually
inherited class.

Discussion on comp.std.c++ :
http://groups-beta.google.com/group/comp.std.c++/browse_thread/thread/0d8cf2d93117bfa1#3f6fda6a03cb5c6a

Diagnostics :

/gcc/gcc-4.0-20041128-build/bin/g++ -o xx virt_inhr_vcbug.cpp
virt_inhr_vcbug.cpp: In constructor ‘Interface::Interface()’:
virt_inhr_vcbug.cpp:4: error: ‘controller::controller()’ is private
virt_inhr_vcbug.cpp:22: error: within this context

Code:

class controller
{
    controller(); // private don't want anyone to call this
    public:
    controller( int ); // this should be called instead
};
 
class Interface
  : virtual public controller
{
    public:
    virtual void DoThing() = 0;
};
 
 
class Application
  : public Interface
{
    public:
    Application()
      : controller( 3 )
    {
    }
 
    void DoThing()
    {
        // Doing it here !
    }
};

-- 
           Summary: abstract classes should not access virtually inherited
                    class constructor
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19249

Reply via email to