public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gsinai at yudit dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/11518] New: (b==a && c==a && c!=b) == true Date: Mon, 14 Jul 2003 12:36:00 -0000 [thread overview] Message-ID: <20030714123632.11518.gsinai@yudit.org> (raw) PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11518 Summary: (b==a && c==a && c!=b) == true Product: gcc Version: 2.96 (redhat) Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gsinai at yudit dot org CC: gcc-bugs at gcc dot gnu dot org,gsinai at yudit dot org (b==a && c==a && c!=b) Tths equation is somtimes true with redhat built gcc 2.6 on Pentiums. a: double type b: function call returning a double c: method call returning a double /*! * \file double.cpp * \brief If a==b and b==c then c==b? Not always. Not everywhere. * \author Gaspar Sinai <gsinai@yudit.org> * \date 2003-07-13. * Results: *-------------------------------------------------------------- * Surprises *-------------------------------------------------------------- * Pentium g++ 2.96: * setting: a_double: 0.1 * setting: get_double(): 0.1 * setting: a_Double.get(): 0.1 * comparing: a_double == get_double() * comparing: a_double == a_Double.get() * comparing: a_Double.get() != get_double() *-------------------------------------------------------------- * Pentium g++ 3.2.1: * setting: a_double: 0.1 * setting: get_double(): 0.1 * setting: a_Double.get(): 0.1 * comparing: a_double != get_double() * comparing: a_double == a_Double.get() * comparing: a_Double.get() != get_double() *-------------------------------------------------------------- * Expected *-------------------------------------------------------------- * Alpha g++ 2.96: * setting: a_double: 0.1 * setting: get_double(): 0.1 * setting: a_Double.get(): 0.1 * comparing: a_double == get_double() * comparing: a_double == a_Double.get() * comparing: a_Double.get() == get_double() *-------------------------------------------------------------- * The interesting function: * static double * get_double(void) * { * int i=1; * // If you change i to 1 it will work everywhere. * return (double (i) / 10.0); * } */ #include <iostream> static double get_double(void); class Double { public: double get(void); void set(double d); protected: double m_d; }; double Double::get (void) { return m_d; } void Double::set (double d) { m_d = d; } static double get_double(void) { int i=1; // If you change i to 1 it will work everywhere. return (double (i) / 10.0); } int main() { double a_double = get_double(); Double a_Double; a_Double.set (get_double()); std::cout << "setting: a_double: " << a_double << std::endl; std::cout << "setting: get_double(): " << get_double() << std::endl; std::cout << "setting: a_Double.get(): " << a_Double.get() << std::endl; if (a_double == get_double()) { std::cout << "comparing: a_double == get_double()" << std::endl; } if (a_double != get_double()) { std::cout << "comparing: a_double != get_double()" << std::endl; } if (a_double == a_Double.get()) { std::cout << "comparing: a_double == a_Double.get()" << std::endl; } if (a_double != a_Double.get()) { std::cout << "comparing: a_double != a_Double.get()" << std::endl; } if (a_Double.get() == get_double()) { std::cout << "comparing: a_Double.get() == get_double()" << std::endl; } if (a_Double.get() != get_double()) { std::cout << "comparing: a_Double.get() != get_double()" << std::endl; } return (0); }
next reply other threads:[~2003-07-14 12:36 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-07-14 12:36 gsinai at yudit dot org [this message] 2003-07-14 12:45 ` [Bug c++/11518] " pinskia at physics dot uc dot edu
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=20030714123632.11518.gsinai@yudit.org \ --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: linkBe 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).