From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26475 invoked by alias); 18 May 2007 13:30:54 -0000 Received: (qmail 26396 invoked by alias); 18 May 2007 13:30:38 -0000 Date: Fri, 18 May 2007 13:30:00 -0000 Message-ID: <20070518133038.26395.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "gdr at cs dot tamu dot edu" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-05/txt/msg01411.txt.bz2 ------- Comment #84 from gdr at cs dot tamu dot edu 2007-05-18 14:30 ------- Subject: Re: [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should "rguenth at gcc dot gnu dot org" writes: | ------- Comment #81 from rguenth at gcc dot gnu dot org 2007-05-18 09:45 ------- | Yes, both testcases are valid and are using placement new. Note the loop | is only to confuse the optimizers enough to re-order the stores and produce | a miscompilation. Note the loop runs exactly once, and in essence we are doing | | int *p = XXX; /* integer memory */ | *p = 0; | long *q = new (p) long; This is OK as long as int and long have same alignment, sizeof, etc. For example, that code is invalid on 64-bit platform where int has alignment and the storage is not large enough to meet long's requirement. This is the case only when the "operator new" is not overloaded, but is the "standard one". The exact conditions are so tricky to explicit that it would just be OK for us to accept it. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286