public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ich at az2000 dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/40186]  New: floating point comparision works wrong ( !(a < b) && (b > a) is true )
Date: Mon, 18 May 2009 13:08:00 -0000	[thread overview]
Message-ID: <bug-40186-17447@http.gcc.gnu.org/bugzilla/> (raw)

When comparing the return value of two functions (which both return double and
do always return the same value), I have the case that (a < b) && (b < a)
(whereby they should be equal) in a real world application.

I tried to reproduce it, though in the test case, I have a slightly different
case, which should be also wrong: !(a < b) && (b > a) is true (whereby it
should be a == b).

Probably both problems are related.

The behaviour pretty much depend on the optimisation. With -O0 and -Os, I am
hitting the problem, but not so with -O1, -O2 and -O3.


-- 
           Summary: floating point comparision works wrong ( !(a < b) && (b
                    > a) is true )
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ich at az2000 dot de
 GCC build triplet: tried with GCC 4.1.2, 4.3.2 and 4.4.0
  GCC host triplet: Gentoo Linux i386
GCC target triplet: Linux i386


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40186


             reply	other threads:[~2009-05-18 13:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18 13:08 ich at az2000 dot de [this message]
2009-05-18 13:11 ` [Bug c++/40186] " ich at az2000 dot de
2009-05-18 13:16 ` ich at az2000 dot de
2009-05-18 13:17 ` ich at az2000 dot de
2009-05-18 13:38 ` [Bug c++/40186] floating point comparison is " ich at az2000 dot de
2009-05-18 14:12 ` pinskia at gcc dot gnu dot org
2009-05-18 14:49 ` pinskia at gcc dot gnu dot org
2009-05-18 14:53 ` sliwa at cft dot edu dot pl
2009-05-18 14:56 ` vincent at vinc17 dot org

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=bug-40186-17447@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).