This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/9412: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag


>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]