Bug 29706 - rejects-valid: missing mem-initializer for virtual base class
Summary: rejects-valid: missing mem-initializer for virtual base class
Status: RESOLVED DUPLICATE of bug 19249
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-03 23:08 UTC by Jens Maurer
Modified: 2013-07-19 08:11 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Maurer 2006-11-03 23:08:08 UTC
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&)
Comment 1 Andrew Pinski 2006-11-03 23:20:31 UTC
I think is really a dup of bug 19249.
Though the problem here is slightly different as B() is fully defined and calls the default constructor which is not defined.

Comeau C/C++ 4.3.8 (Aug 19 2006 13:36:48) for  ONLINE_EVALUATION_Alpha1
Copyright 1988-2006 Comeau Computing.  All rights reserved.
MODE:strict errors C++

"ComeauTest.c", line 7: error: no default constructor exists for class "V"
    B() { }       // does not mention constructor of V
        ^

That is what comeau online gives.
Comment 2 Jens Maurer 2006-11-04 15:34:30 UTC
I agree it's a duplicate of bug 19249, but I would not limit the discussion to abstract classes.

*** This bug has been marked as a duplicate of 19249 ***