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]

Re: gcc bug report


Correct, however, the following modified code seems to exhibit a compiler 
bug:

#include <stdio.h>

class A {
public:
  A () { printf ("A **bad**\n"); }
  A (int g) { printf ("A %d\n", g); }
};

class B : public A {
public:
  B () : A (2) {}
};

class C : public virtual A, public B {
public:
  C () : A (3), B () {}
};

int
main ()
{
  C c;
}

--Petar



On Wed, 7 Jan 2004, Zack Weinberg wrote:

> Petar Maymounkov <petar@scs.cs.nyu.edu> writes:
> 
> > (a) gcc -v:
> > Using builtin specs.
> > gcc version 2.95.4 20020320 [FreeBSD]
> >
> > (b) uname -a:
> > FreeBSD williamsburg-bridge.scs.cs.nyu.edu 4.7-RELEASE FreeBSD 4.7-RELEASE 
> > #0: Wed Oct  9 15:08:34 GMT 2002     
> > root@builder.freebsdmall.com:/usr/obj/usr/src/sys/GENERIC  i386
> >
> > (c) command line that triggers bug:
> > gcc proxy.C
> >
> > (d) compiler output:
> > (NONE)
> >
> > (e) proxy.C and proxy.ii are attached.
> 
> You don't say what the bug is.  I am guessing that it's that the
> no-argument A constructor gets called instead of A(int) when the
> program is run.  This is the behavior specified by the standard.
> The key sentence is in paragraph 6 of [class.base.init]:
> 
>   A _mem-initializer_ naming a virtual base class shall be ignored
>   during execution of the constructor of any class that is not the
>   most derived class.
> 
> zw
> 


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