|
Date: Tue, 25 Nov 2014 16:25:00 +0100 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: [PATCH 1/4] the CMPLX macros must be usable in initializations of static variables * Jens Gustedt <Jens.Gustedt@...ia.fr> [2014-11-25 15:49:39 +0100]: > diff --git a/include/complex.h b/include/complex.h > index 13a45c5..3e14e04 100644 > --- a/include/complex.h > +++ b/include/complex.h > @@ -112,8 +112,7 @@ long double creall(long double complex); > #define cimagf(x) __CIMAG(x, float) > #define cimagl(x) __CIMAG(x, long double) > > -#define __CMPLX(x, y, t) \ > - ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z) hm the compound literal is not a constant expression that is sad > +#define __CMPLX(x, y, t) ((t)(x) + _Complex_I*(t)(y)) > this is only correct if the compiler supports annex g kind of imaginary type, otherwise it is incorrect for infinites _Complex_I*INFINITY == (0 + i)*(inf + i*0) == nan + i*inf so imaginary inf will turn into nan real part this is what gcc (and i assume clang) does > #define CMPLX(x, y) __CMPLX(x, y, double) > #define CMPLXF(x, y) __CMPLX(x, y, float) > -- > 1.9.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.