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



             Bug #: 55267

           Summary: double operation giving different results depending on

                    context and optimization level

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: major

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: jkuittinen293...@gmail.com





/*

 * 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;

}

Reply via email to