public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/9412: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag
@ 2003-01-23 2:26 martin
0 siblings, 0 replies; only message in thread
From: martin @ 2003-01-23 2:26 UTC (permalink / raw)
To: gcc-gnats
>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 <cassert>
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:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-01-23 2:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-23 2:26 optimization/9412: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).