You could try building with -std=c++03 to test if that solves the problem.

I am assuming that the code is something like this:

double COMPLEX::real() const { return this->real_value; }
double COMPLEX::imag() const { return this->imag_value; }

in which case the two assert()s you have are broken assumptions, in both
emscripten and native: the assert()s won't hold if you take the address of
a temporary, they'll be pointing to something else. If you change your code
to something like

const double &COMPLEX::real() const { return this->real_value; }
const double &COMPLEX::imag() const { return this->imag_value; }
double &COMPLEX::real() { return this->real_value; }
double &COMPLEX::imag() { return this->imag_value; }

or

    COMPLEX x;
    COMPLEX* px = &x;
    double* prx = &x.real_value;
    double* pix = &x.imag_value;
    assert(reinterpret_cast<void*>(prx) == reinterpret_cast<void*>(px));
    assert(reinterpret_cast<void*>(pix-1) == reinterpret_cast<void*>(px));

then that should fix the code up. The first form returns by reference
rather than by value, and the second form directly takes in addresses of
the actual COMPLEX member vars proper, and not some temporaries.


2014-07-10 6:08 GMT+03:00 nunya biznez <[email protected]>:

> I'm trying to compile some c++ code and I have some issues with using the
> complex library.
> The code does some funny pointer stuff with the complex class like this:
>
>     COMPLEX x;
>     COMPLEX* px = &x;
>     double* prx = &x.real();
>     double* pix = &x.imag();
>     assert(reinterpret_cast<void*>(prx) == reinterpret_cast<void*>(px));
>     assert(reinterpret_cast<void*>(pix-1) == reinterpret_cast<void*>(px));
>
> and this:
>
>     tr_load_point(_n[ii], _n[jj], &(_matrix[nii][njj].real()),
> &(_matrix[nii][njj].imag()));
>
> The error I get is cannot take the address of an rvalue of type 'double'.
>
> I get the same errors when I use clang by itself with "-std=c++11 " ,but
> it compiles fine without that setting.
> Same thing with gcc.
>
> I was hoping a compiler setting for emscripten would solve the problem.
>
> Thanks.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to