This is the mail archive of the gcc-patches@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]

Re: PR c++/5645 gcc warns that pure virtual class not explicitly initialized


On 12/11/2007, Jason Merrill <jason@redhat.com> wrote:
> Manuel López-Ibáñez wrote:
> > And I am not sure how it is possible to check that the base class copy
> > constructor is not user-defined. I wasn't able to find an appropriate
> > function to do this.
>
> I was suggesting that we check for any user-defined constructor.
>

My question was: is there any function to find out that?

For this testcase:

class a {
public:
  virtual int f() = 0;
  virtual int g() = 0;
};

class b : public a {
public:
  b();
  b(const b& c);

protected:
  int i;
};

b::b() {}

b::b(const b& c) { // { dg-bogus "base class .class a. should be
explicitly initialized in the copy constructor" }
  i = c.i;
}

In init.c (emit_mem_initializers) a subobject is a BINFO of the
CURRENT_CLASS_TYPE, then:

TYPE_HAS_CONSTRUCTOR (BINFO_TYPE (subobject)) is 1.
TYPE_HAS_COMPLEX_INIT_REF (BINFO_TYPE (subobject)) is 1.
TYPE_HAS_COMPLEX_DFLT (BINFO_TYPE (subobject)) Is 1.

which is not what I expected from those functions. I guess I am
misunderstanding something here.

Cheers,

Manuel.


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