unaryExpr deduces wrong return type on MSVC
Summary
unaryExpr has regressed and does not infer the correct return type.
The below code fails to compile on master or 3.4 branch heads. It previously worked on master. git bisect leads to the commit below as the first time it fails.
The error is due to unaryExpr not deducing the return type of the lambda, and instead returning the same type as the base expression. Here, it should return Array, but it is returning Array and failing to assign to Array.
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
Environment
- Operating System : Windows 10
- Architecture : x64.
- Eigen Version : 0bdc0dba
- Compiler Version : Visual Studio Community 2019
- Compile Flags : cmake Debug build defaults (run by VS cmake support)
- Vector Extension : whatever cmake detects and enables by default.
Minimal Example
ArrayXXf a(1,6);
a << 1,2,3, 4,5,6;
ArrayXXi b = a.unaryExpr([](float f){ return (int)f;});