Segfault when returning IndexedView of local Reshaped expression
When returning an IndexedView from a function, I happened across the following behaviour:
- Using an Eigen::Array local to the function as the indices for the IndexedView is fine.
- Using that same Array of indices, but just calling ```reshaped()``` on it, when creating the IndexedView, causes a segfault.
- Using that same Array of indices, but calling ```reshaped().eval()``` on it is fine.
Is this expected/intended behaviour?
```
#include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
decltype(auto) firstCol( const ArrayXXd& values ){
/* this works */
// return values( all, Array<int,1,1>{0} );
/* this causes a segmentation fault */
return values( all, Array<int,1,1>{0}.reshaped() );
/* evaluating the expression also makes it work */
// return values( all, Array<int,1,1>{0}.reshaped().eval() );
}
int main(){
ArrayXXd values (2,6);
values = 0;
std::cout << "First column:\n" << firstCol(values) << "\n";
return 0;
}
```
EDIT: Using Ubuntu 20.04 and gcc 9.3.0 with C++17. Eigen version: Developer branch, commit hash d53ae40f (from mid January, gonna try the newest now).
EDIT2: Problem persists with latest version, commit hash dcf7655b (from yesterday, July 11th)
issue