Assert if temporary objects that are still referred to get destructed (was: Misbehaving Product on C++11)

Submitted by bre..@..il.com

Assigned to Nobody

Link to original bugzilla bug (#505)
Version: 3.4 (development)

Description

This very well could be a GCC 4.7 -std=c++11 issue, but here is the code and output:

#include <iostream>
#include <Eigen/Dense>

using namespace std;
using namespace Eigen;

template<class A, class B, class C>
double combine(const A& a, const B& b, const C& c)
{
auto result = a*b-c;
cout << result << endl;
return result(0,0);
}

int main()
{
Matrix<double,1,1> X, y, w, g;
X << 4;
y << 2;
w << 4;

cout << combine(X,y,w) << endl;  
cout << X*y-w << endl;  

return 0;  

}

Build:
g++ -c -O3 -Wall -Ic:/C++/include -std=c++11 main.cpp -o main.o
g++ -Lc:/C++/lib main.o -lgtest -o main.exe
rm main.o

Output:
-4
-4
4

Error goes away when I remove -O3.

Depends on

#99 (closed) #825 (closed)

Blocking

#814 (closed) #646 (closed)

Edited by Eigen Bugzilla