Created attachment 22387
testcase
The attached testcase's behavior is different when it is built with -O2 and
without -O2.
With -O2 it fails with this Eigen exception:
> Assertion failed: (lhs.cols() == rhs.rows() && "invalid matrix product" &&
"if you wanted a coeff-wise or a dot product use the respective explicit
functions"), function Product, file
/usr/local/include/eigen3/Eigen/src/Core/Product.h, line 97.
> Abort trap
Without -O2 it doesn't print the exception and succeeds.
The line labeled with "// BUG" seems to be related.
It produces some Eigen-specific type
(N5Eigen7ProductINS_6MatrixIdLin1ELin1ELi0ELin1ELin1EEES2_Li0EEE) in place of
"auto" that later crashes with -O2.
If this "auto" is replaced with "M" (regular matrix) - it doesn't crash with -
O2.
While looking at this code, I can't tell why does it fail conditionally on -O2
like this. Nothing there alters that matrix, or any arguments of that
multiplication.
Optimization level should not trigger changes of behavior like this, especially
additional asserts.
clang-8 and clang-9 on FreeBSD 12 amd64.
llvm-auto-no-assert-without-optimization.tgz
(523673 bytes, application/x-compressed-tar)