public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: martin@xemacs.org
To: gcc-gnats@gcc.gnu.org
Subject: optimization/9412: g++ 3.4 generates incorrect code with -O2 flag, but not -O flag
Date: Thu, 23 Jan 2003 02:26:00 -0000	[thread overview]
Message-ID: <20030123022154.13518.qmail@sources.redhat.com> (raw)


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


                 reply	other threads:[~2003-01-23  2:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030123022154.13518.qmail@sources.redhat.com \
    --to=martin@xemacs.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).