From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16468 invoked by alias); 23 Jan 2003 02:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 16449 invoked by uid 71); 23 Jan 2003 02:26:00 -0000 Resent-Date: 23 Jan 2003 02:26:00 -0000 Resent-Message-ID: <20030123022600.16448.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, martin@xemacs.org Received: (qmail 13519 invoked by uid 48); 23 Jan 2003 02:21:54 -0000 Message-Id: <20030123022154.13518.qmail@sources.redhat.com> Date: Thu, 23 Jan 2003 02:26:00 -0000 From: martin@xemacs.org Reply-To: martin@xemacs.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: optimization/9412: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag X-SW-Source: 2003-01/txt/msg01311.txt.bz2 List-Id: >Number: 9412 >Category: optimization >Synopsis: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag >Confidential: no >Severity: critical >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Thu Jan 23 02:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Martin Buchholz >Release: g++ (GCC) 3.4 20030122 (experimental) >Organization: >Environment: Linux x86 >Description: The source file below compiles and executes successfully with g++ (GCC) 3.3 20030122, g++ 3.2.1, g++ 2.95 at any optimization level, and with g++ 3.4 20030122 at -O. However, with g++ 3.4 20030122 at -O2, we get: (martin@wobble) ~/src/toy/Bug-gcc34 $ g++ -Wall -O2 main.cc -o main && ./main main: main.cc:21: int main(int, char**): Assertion `id (Bool (false)) == false' failed. Source file follows: -------------------------------------------------- #include class Bool { public: const bool val_; Bool (bool x) : val_ (x) {} struct S_ { int M_; }; operator int S_::* () const { return val_ ? & S_::M_ : 0; } friend bool operator== (Bool x, bool y) { return bool (x) == y; } }; Bool id (Bool x) { return x; } int main (int argc, char *argv[]) { assert (Bool (false) == false); assert (Bool (Bool (false)) == false); assert (id (Bool (false)) == false); return 0; } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: