[Bug c++/13064] getting address of a virtual base before its construction causes a crash

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Nov 16 00:51:00 GMT 2003


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-11-16 00:51 -------
The problem is that the lifetime of b has not been started yet so you get a crash (optimizing will 
remove the crash only because of inlining) so the behavior is undefined.

>From the C++ standard, 2.8 [basic.life]:
The liftime of an object of type T begins when:
— storage with the proper alignment and size for type T is obtained and  (this is true but)
— if T is a class type with a non-trrivial constructor (12.1), the constructor has completed (this is 
not so the behavior is undefined and could cause a crash).

>From 12.1.5 (Constructors):
A constuctor is trival if it is an implictly-declared default constructor (this is not true in this 
example)  and if ....

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13064



More information about the Gcc-bugs mailing list