From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6626 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 20:21:51 +0100 Message-ID: <20141125192150.GA2541@port70.net> References: <1416926830.16006.923.camel@eris.loria.fr> <20141125152500.GF5488@port70.net> 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 1416943331 26600 80.91.229.3 (25 Nov 2014 19:22:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2014 19:22:11 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6639-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 25 20:22:06 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 1XtLgb-0006Zg-Hd for gllmg-musl@m.gmane.org; Tue, 25 Nov 2014 20:22:05 +0100 Original-Received: (qmail 21722 invoked by uid 550); 25 Nov 2014 19:22:03 -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 21714 invoked from network); 25 Nov 2014 19:22:02 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20141125152500.GF5488@port70.net> User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:6626 Archived-At: * 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) http://gcc.gnu.org/ml/gcc-patches/2011-08/msg01600.html 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)