egcs-980517 bug report

Brendan Kehoe brendan@cygnus.com
Thu May 21 15:27:00 GMT 1998


dcb@pncl.co.uk (David C Binderman) writes:

> Hello there,
> 
> I think the following C++ code should not compile
> 
> // this should fail
> 
> union U {
> 	U();
> 	int & ri;
> };

You actually can; from $9.5 of the draft standard:


  A union  can  have  member functions  (including  constructors  and
  destructors), but not virtual functions. 

If you try to declare a method virtual, g++ will give an error.

-- 
Brendan Kehoe                                               brendan@cygnus.com
Cygnus Solutions, Sunnyvale, CA                                +1 408 542 9600

Web page: http://www.zen.org/~brendan/



More information about the Gcc-bugs mailing list