This code snippet

struct V {
  V(int) { }
};

struct B : virtual V
{
  B() { }       // does not mention constructor of V
};

struct D : B
{
  D() : V(0) { }
};

D d;     // most derived object of type D

should be valid according to the C++ standard 12.6.2 paragraph 6 (note that B
is not a most derived class).  However, gcc complains about the definition of
the constructor for B, which is wrong, because the constructor for B is not
used to initialize a most derived object (it only initializes the B subobject
of D):

257-demo.cc: In constructor 'B::B()':
257-demo.cc:7: error: no matching function for call to 'V::V()'
257-demo.cc:2: note: candidates are: V::V(int)
257-demo.cc:1: note:                 V::V(const V&)


-- 
           Summary: rejects-valid: missing mem-initializer for virtual base
                    class
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jens dot maurer at gmx dot net
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to