I encountered a strange behavour and I would like
to ask if anyone can confirm it.
In cppunit-1.10.2
when I compile the example in examples/simple with optimization, e.g:
g++ -O2 -o foo Main.cpp ExampleTestCase.cpp -lcppunit -ldl
then the output is as expected:
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZero : OK
ExampleTestCase::testEquals : assertion
ExampleTestCase.cpp:7:Assertion
Test name: ExampleTestCase::example
equality assertion failed
- Expected: 1
- Actual : 1.1
...[snip]
However when I compile the same example without
-O2 flag then the output is just:
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZeroFloating point exception
Well I did also some other tests and it seems to me
that optimization changes the code behaviour drastically.
I checked it with gcc (GCC) 3.4.1 as well as with
gcc 2.95.4
I would appreciate any comment on this.
Thanks,
Roman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I encountered a strange behavour and I would like
to ask if anyone can confirm it.
In cppunit-1.10.2
when I compile the example in examples/simple with optimization, e.g:
g++ -O2 -o foo Main.cpp ExampleTestCase.cpp -lcppunit -ldl
then the output is as expected:
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZero : OK
ExampleTestCase::testEquals : assertion
ExampleTestCase.cpp:7:Assertion
Test name: ExampleTestCase::example
equality assertion failed
- Expected: 1
- Actual : 1.1
...[snip]
However when I compile the same example without
-O2 flag then the output is just:
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZeroFloating point exception
Well I did also some other tests and it seems to me
that optimization changes the code behaviour drastically.
I checked it with gcc (GCC) 3.4.1 as well as with
gcc 2.95.4
I would appreciate any comment on this.
Thanks,
Roman