[eigen] wrong result when not inlining (at least with vs.net)

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

after debugging for a long long time I found out that the attached
trivial test program does not print out a zero when the operator

106: operator* (const Transform<Scalar,Dim,Mode>& tr, const Homogeneous& rhs)

from the Homogenous header is not inlined. As the topic indicates this
test is currently only true for VC++ 2008 (9.0.30729.1 SP).

The result turns out to be correct as soon as

Configuration Properties -> C/C++ -> Optimization -> Inline Function
Expansion -> /Ob1 or /Ob2

as a consequence one has to set

Configuration Properties -> C/C++ -> General -> Debug Information
Format -> /Zi (not /ZI)

I have no clue what is the reason for this behaviour and I also tried
to isolate the problem by extracting ei_homogeneous_left_product_impl
into a test program but as soon as the operator* call is gone, it is
working. What happens when the function is not inlined is that
ei_homogeneous_right_product_impl::m_lhs becomes invalid when the
function reaches the body of

244: template<typename Dest> void evalTo(Dest& dst) const

even though in the ctor ei_homogeneous_right_product_impl::m_lhs is
still valid and can even be printed.

I have no clue what happens on other systems or where exactly this
subtle error is coming from. If other VC++ users could confirm the
issue or in case somebody could point me to the actual problem it
would be more than welcome.

Regards,
Hauke

p.s. I did not check the MSDN knowledge base whether this is a known
compiler issue or such.

Attachment: main.cpp
Description: Binary data



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/