From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25433 invoked by alias); 18 May 2007 08:46:10 -0000 Received: (qmail 25336 invoked by uid 48); 18 May 2007 08:45:56 -0000 Date: Fri, 18 May 2007 08:46:00 -0000 Message-ID: <20070518084556.25335.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: "rguenth at gcc dot gnu dot org" 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/msg01394.txt.bz2 ------- 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; *q = -1; and the compiler is re-ordering the stores which is wrong. *p and *q need to alias because of the placement new. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286