Wrong return value for transpose
Summary
I have some unexpected results when using the transpose method.
Environment
- Operating System : Windows
- Architecture : x64
- Eigen Version : 3.4.0
- Compiler Version : MSVC 19.34.31944
- Compile Flags : /Oxt /std:c++20 /EHs
Minimal Example
#include "Eigen/Dense"
#include <iostream>
std::pair<Eigen::Vector2d, double> func() {
return { Eigen::Vector2d{11, 0}, 0 };
};
int main(int argc, char *argv[]) {
const Eigen::Vector2d &result = func().first;
std::cout << *result.data() << " " << *(result.data() + 1) << std::endl;
std::cout << result.transpose() << std::endl;
std::cout << func().first.transpose() << std::endl;
return 0;
}
What is the expected correct behavior?
I expect the output:
11 0
11 0
11 0
What is the current bug behavior?
I have the output:
11 0
6.95158e-310 6.95145e-310
11 0
Anything else that might help
I initially asked my question on stackoverflow as I thought I might have been doing a c++ mistake, but now I wonder if it might be linked to Eigen. I know that getting the result of the function as a const reference is controversial but I do not think it is a mistake here. I am out of ideas and I cannot figure out why I have this behavior.
Edited by pierreXVI