I have a strange problem with mingw-w64, gcc-5.2.0 in 32bits on windows
in release. The following code leads to a crash (it is working in 64
bits and in debug). The adress of return in the stack seems to be
broken. I was not able to reduce it more than this, and in particular I
am not able to remove BOOST_CHECK_CLOSE (using BOOST_CHECK_EQUAL works).
This can be either a bug in gcc (false code generation) or something
else. How can I investigate ?
#define BOOST_TEST_MODULE MyTest
#include
#include <iostream>
struct P
{
P(double x_, double y_): x(x_), y(y_) {}
double x;
double y;
};
struct Seg
{
Seg(const P & o_, const P & e_): o(o_), e(e_) {}
P o;
P e;
};
void f()
{
auto Check = [](const Seg & s1, const Seg & s2,
bool expected_common_cut, double expected_length) {
std::cerr << expected_length << std::endl;
BOOST_CHECK_CLOSE(1e-3, 1e-4, .1);
};
Check(Seg(P(0, 0), P(100, 0)), Seg(P(0, 0), P(100, 0)), false, 0.0);
Check(Seg(P(0, 0), P(100, 0)), Seg(P(100, 0), P(0, 0)), true, 100.0);
std::cerr << "STILL LEAVING !" << std::endl;
}
void g()
{
std::cerr << "BEFORE CRASH" << std::endl;
f();
std::cerr << "NEVER PRINTED" << std::endl;
}
BOOST_AUTO_TEST_CASE( my_test )
{
g();
}