On Wed, May 15, 2019 at 10:41:06PM +0300, Janne Blomqvist wrote: > > 2) I don't think float _Complex is > > passed the same as std::complex<float> and similar for others; > > std::complex<float> is in libstdc++ a C++ class with with > > __complex__ float as its sole non-static data member and with non-trivial > > constructors; which means it is passed/returned via a hidden reference; > > when the argument is actually FLOAT_COMPLEX * or FLOAT_COMPLEX &, > > you except for aliasing don't have to care that much, but if > > that complex argument has VALUE attribute in Fortran and so the > > C prototype would be FLOAT_COMPLEX, then std::complex<float> is > > passed in the end as std::complex<float> &, while float _Complex > > the same as __complex__ float; and ditto for functions returning > > complex > > Ugh, I guess that's right. Any good way around it? Except print a > warning in the header that passing std::complex<> by value doesn't > work?
Perhaps we can use different macros for the two cases, define __GFORTRAN_FLOAT_COMPLEX to std::complex<float> and __GFORTRAN_FLOAT_COMPLEX_VALUE to __complex__ float and use the former in the __GFORTRAN_FLOAT_COMPLEX * arguments and the latter for VALUE dummy args and return value. For the return value case, guess it will be fine, when one does __complex__ float fortran_fn_ (void); std::complex<float> ret = fortran_fn_ (); it will work just fine, but for the arguments trying to void fortran_sub_ (__complex__ float); std::complex<float> f = 2.0f + 4.0fi; fortran_sub_ (f); will not work (but one will get at least errors). One can use non-standard fortran_sub_ (f.__rep ()); Jakub