xtensor
xtensor copied to clipboard
`xt::real(...)` crashes the program when printed to `cout`
Behaviour
When I try to print the real(or imag) part of a complex xarray to cout, it crashes and prints nothing:
#include <iostream>
#include <complex>
using namespace std;
#include "xtensor/xarray.hpp"
#include "xtensor/xcomplex.hpp"
#include "xtensor/xio.hpp"
typedef std::complex<double> cpx;
int main()
{
// bug present only with xarray; everything's fine for xtensor
xt::xarray<std::complex<double>> U = {
{cpx(1, 2), cpx(3, 4)},
{cpx(5, 6), cpx(7, 8)}
};
cout << "hello" << endl; // not printed either
cout << xt::real(U) << endl; // nothing is printed
return 0;
}
After compiling and run on my computer, nothing is printed, not even the first line, indicating that cout<<xt::real(U)<<endl has crashed the whole program silently.
This bug only happens for xarray; when I replace xarray with xtensor, it works.
Environment
My dev environment is Windows, mingw-w64 8.1.0, running on a Intel i7 CPU.
I get the following output on MSVC 2022
hello
{{ 1., 3.},
{ 5., 7.}}