This is the mail archive of the gcc@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: Is this a bug for gcc (2.95 and 3.1)?


Hi,

Your two programs are invalid WRT the C++ standard: ONLY virtual functions
can be declared as "pure" by the provided "=0" syntax. However destructors
are NOT functions as, even if they are declared "virtual" they cannot be
inherited but are ratger sythesized by the compiler if they are not defined.

Note that in fact this indeed reveal a bug in GCC (and that's the reason I
do not qualify your post as off-topic): the compiler should flag your
programs with an error message, reporting that it's illegal to declare a
destructor as pure; I do not check the output of gcc for the first program
to see what diagnostic was provided, but the second one should definitely be
rejected with the same error message.

HTH

        Bernard

--------------------------------------------
Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
92400 COURBEVOIE
FRANCE
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85
e-mail:	dautrevaux@microprocess.com
--------------------------------------------  

> -----Original Message-----
> From: Mitchell Maggie [mailto:maggie_shh@hotmail.com]
> Sent: Friday, May 24, 2002 5:29 AM
> To: gcc@gcc.gnu.org
> Subject: Is this a bug for gcc (2.95 and 3.1)?
> 
> 
> HI,All:
> There are two problem about g++.
> OS:
> CYGWIN_NT-5.0 MAGGIE 1.3.10(0.51/3/2) 2002-02-25 11:14 i686 unknown
> 1:
> this program can not pass compilation by gcc2.95 and gcc3.1
> 
> //code strat
> #include <stdio.h>
> class A
> {
> public:
>   virtual ~A()=0
>         {
>         };
> };
> class B:public A
> {
> };
> 
> int main()
> {
> B b;
> return 1;
> };
> //code ends 
> 
> 2:This program will cause gcc3.1 link error ,but passed by gcc2.95
> //code begin
> #include <stdio.h>
> class A
> {
> public:
>   virtual ~A()=0;
> //      {
> //      };
> };
> A::~A()
> {
> }
> class B:public A
> {
> };
> 
> int main()
> {
> B b;
> return 1;
> };
> //code ends
> 
> Why?
> 
> Regards
>     Maggie
> 
> _________________________________________________________________
>  MSN Explorerhttp://explorer.msn.com/lccn/intl.asp
> 


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