Bug 55267 - double operation giving different results depending on context and optimization level
Summary: double operation giving different results depending on context and optimizati...
Status: RESOLVED DUPLICATE of bug 323
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-10 17:47 UTC by Jari Kuittinen
Modified: 2012-11-12 14:53 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jari Kuittinen 2012-11-10 17:47:24 UTC
/*
 * the following code outputs ":o" on 4.7.2 when compiled with -O0
 * and ":)" when compiled with -O1
 *
 */

#include <iostream>

class Plap
{
public:
    double value;

    Plap(int a, int b)
    {
        value = (double)a / (double)b;
    }
};


int main()
{
    int i = 1;
    int j = 3;

    Plap plap(i, j);

    if (plap.value != ((double)i / (double)j))
        std::cout << ":o" << std::endl;
    else
        std::cout << ":)" << std::endl;


    return 0;
}
Comment 1 Andrew Pinski 2012-11-10 17:49:20 UTC
I bet this is a dup of bug 323.
Comment 2 Paolo Carlini 2012-11-12 14:53:28 UTC
Dup

*** This bug has been marked as a duplicate of bug 323 ***