From owner-svn-src-head@FreeBSD.ORG Thu Jan 5 12:05:48 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAAC5106566B; Thu, 5 Jan 2012 12:05:48 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5CD58FC15; Thu, 5 Jan 2012 12:05:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q05C5muR034367; Thu, 5 Jan 2012 12:05:48 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q05C5mOG034365; Thu, 5 Jan 2012 12:05:48 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201201051205.q05C5mOG034365@svn.freebsd.org> From: Ed Schouten Date: Thu, 5 Jan 2012 12:05:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229590 - head/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2012 12:05:49 -0000 Author: ed Date: Thu Jan 5 12:05:48 2012 New Revision: 229590 URL: http://svn.freebsd.org/changeset/base/229590 Log: Make _Complex_I a proper float _Complex when using GCC 4.2. It turns out our GCC has quite an interesting bug: typeof(1.0fi) != float _Complex typeof((float _Complex)1.0fi) != float _Complex typeof((float _Complex)1.0i) == float _Complex In other words: if casting to an equal size, GCC seems to take a shortcut. By casting down from a double to a float, GCC doesn't take this shortcut, yielding the proper type. To prevent foot-shooting, add a _Static_assert() to guarantee that _Complex_I is always a float _Complex. I'm not going to MFC this part of the diff. MFC after: 2 weeks Modified: head/include/complex.h Modified: head/include/complex.h ============================================================================== --- head/include/complex.h Thu Jan 5 11:45:22 2012 (r229589) +++ head/include/complex.h Thu Jan 5 12:05:48 2012 (r229590) @@ -29,11 +29,15 @@ #ifndef _COMPLEX_H #define _COMPLEX_H +#include + #ifdef __GNUC__ #if __STDC_VERSION__ < 199901 #define _Complex __complex__ #endif -#define _Complex_I 1.0fi +#define _Complex_I ((float _Complex)1.0i) +_Static_assert(__generic(_Complex_I, float _Complex, 1, 0), + "_Complex_I must be of type float _Complex"); #endif #define complex _Complex