This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question about -fall-virtual
- To: egcs at cygnus dot com
- Subject: Re: Question about -fall-virtual
- From: jsimon at sunchorus dot france dot sun dot com (Julien SIMON - APRIME)
- Date: Mon, 22 Jun 1998 12:12:57 +0200
- Cc: egcs-bugs at cygnus dot com
> From owner-egcs@cygnus.com Sun Jun 21 23:29:10 1998
> Date: Sun, 21 Jun 1998 19:03:04 +0200 (MET DST)
> From: =?ISO-8859-1?Q?Fredrik_=D6hrstr=F6m?= <d92-foh@nada.kth.se>
> To: egcs@cygnus.com
> Subject: Question about -fall-virtual
> MIME-Version: 1.0
>
>
> Have I misunderstood the -fall-virtual switch purpose?
>
> I thought that it would do:
> treat every member function as virtual, even if they are not
> prefixed by "virtual".
>
> However the following simple code:
> #include<iostream.h>
>
> struct A
> {
> int hi () { return 0; }
> };
>
> struct B : public A
> {
> int hi () { return 4; }
> };
>
> int main ()
> {
> A *a = new B;
>
> cout << a->hi () << endl;
> }
>
> Compiled with -fall-virtual (egcs1.0.3) still prints the answer 0.
> When I do as I should do according to the standard (that is prefix A::hi with
> virtual), it prints 4 like it should.
>
FWIW, this program fails to compile with egcs-19980615 on Solaris 2.6 :
In file included from /local/egcs-19980615/include/g++/iostream.h:31,
from virt.C:1:
/local/egcs-19980615/include/g++/streambuf.h:260: Internal compiler error.
/local/egcs-19980615/include/g++/streambuf.h:260: Please submit a full bug report to `egcs-bugs@cygnus.com'.
Julien