Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 25 Nov 2014 20:21:51 +0100
From: Szabolcs Nagy <>
Subject: Re: [PATCH 1/4] the CMPLX macros must be usable in
 initializations of static variables

* Szabolcs Nagy <> [2014-11-25 16:25:00 +0100]:
> * Jens Gustedt <> [2014-11-25 15:49:39 +0100]:
> > -#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
> > +#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

it seems gcc added __builtin_complex but there is no easy way to check
for the availability of such builtin (other than checking >= gcc 4.7)

i guess we could use the builtin with gcc version check and fall back
to the compound literal version otherwise (it wont work as static
initializer then, but right now the biggest user of CMPLX is most
likely musl src/complex/* which dont need it to be constant expr
but does rely on proper semantics for infinites and signed zeros)

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.