Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xt::real(...) crashes the program when printed to cout #2764

Open
IcyChlorine opened this issue Jan 10, 2024 · 1 comment
Open

xt::real(...) crashes the program when printed to cout #2764

IcyChlorine opened this issue Jan 10, 2024 · 1 comment

Comments

@IcyChlorine
Copy link

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.

@spectre-ns
Copy link
Contributor

I get the following output on MSVC 2022

hello
{{ 1.,  3.},
 { 5.,  7.}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants