From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6625 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 1/4] the CMPLX macros must be usable in initializations of static variables Date: Tue, 25 Nov 2014 16:25:00 +0100 Message-ID: <20141125152500.GF5488@port70.net> References: <1416926830.16006.923.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1416929121 6880 80.91.229.3 (25 Nov 2014 15:25:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 15:25:21 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6638-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 25 16:25:14 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XtHzO-0000C4-0z for gllmg-musl@m.gmane.org; Tue, 25 Nov 2014 16:25:14 +0100 Original-Received: (qmail 30424 invoked by uid 550); 25 Nov 2014 15:25:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30416 invoked from network); 25 Nov 2014 15:25:12 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <1416926830.16006.923.camel@eris.loria.fr> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:6625 Archived-At: * Jens Gustedt [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