From owner-freebsd-standards@FreeBSD.ORG Mon Jul 29 15:42:50 2013 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D7079555; Mon, 29 Jul 2013 15:42:49 +0000 (UTC) (envelope-from pasi.parviainen@iki.fi) Received: from sinikuusama.dnainternet.net (sinikuusama.dnainternet.net [83.102.40.134]) by mx1.freebsd.org (Postfix) with ESMTP id 4F43C2E17; Mon, 29 Jul 2013 15:42:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sinikuusama.dnainternet.net (Postfix) with ESMTP id 6D0393FC82; Mon, 29 Jul 2013 18:33:26 +0300 (EEST) X-Virus-Scanned: DNA Postiturva at dnainternet.net X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-9999 required=6 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from sinikuusama.dnainternet.net ([83.102.40.134]) by localhost (sinikuusama.dnainternet.net [127.0.0.1]) (DNA Postiturva, port 10041) with ESMTP id FkjCMZS4ItnD; Mon, 29 Jul 2013 18:33:25 +0300 (EEST) Received: from oliivipuu.dnainternet.net (oliivipuu.dnainternet.net [83.102.40.215]) by sinikuusama.dnainternet.net (Postfix) with ESMTP id D829C3FA63; Mon, 29 Jul 2013 18:33:25 +0300 (EEST) Received: from [192.168.0.2] (host-109-204-160-251.tp-fne.tampereenpuhelin.net [109.204.160.251]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oliivipuu.dnainternet.net (Postfix) with ESMTPS id 6278A5FAA6; Mon, 29 Jul 2013 18:33:16 +0300 (EEST) Message-ID: <51F68ACA.8030500@iki.fi> Date: Mon, 29 Jul 2013 18:31:22 +0300 From: Pasi Parviainen User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Raphael Kubo da Costa Subject: Re: CURRENT: CLANG 3.3 and -stad=c++11 and -stdlib=libc++: isnan()/isninf() oddity References: <20130710155809.0f589c22@thor.walstatt.dyndns.org> <20130710183315.725dfde0@thor.walstatt.dyndns.org> <20130710203200.5359fd18@thor.walstatt.dyndns.org> <51DDC04B.6040209@FreeBSD.org> <20957.49978.73666.392417@khavrinen.csail.mit.edu> <20130711130043.R920@besplex.bde.org> <20130711202908.L84170@besplex.bde.org> <20130712234749.5afa3c9b@thor.walstatt.dyndns.org> <9B0A6D14-640E-4ADD-8E58-0B7867C7C674@FreeBSD.org> <51E145CC.8080900@iki.fi> <861u6iv0ih.fsf@orwell.Elisa> <83zjt5mwri.fsf@FreeBSD.org> In-Reply-To: <83zjt5mwri.fsf@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Scot Hetzel , "freebsd-standards@FreeBSD.org" , "freebsd-toolchain@FreeBSD.org" , Garrett Wollman , FreeBSD Current , Tijl Coosemans , "O. Hartmann" X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jul 2013 15:42:50 -0000 On 29.7.2013 14:27, Raphael Kubo da Costa wrote: > David Chisnall writes: > >> On 28 Jul 2013, at 22:27, Raphael Kubo da Costa wrote: >> >>> This seems to have been committed in r253321, and broke some code that >>> was working with r253320; namely, some code in x11/kde4-workspace >>> includes math.h and calls isnan() with a const double. >> >> Please provide a test case. Specifically, I need to know what >> language dialect this is using, because I have tested including math.h >> and calling isnan(double) with c89, gnu89, c99, c11, c++03 and c++11 >> on gcc (for the modes that it supports) and clang. > > I get the following results with and without -std=c++11 and/or > -stdlib=libc++: > > % cat isnan.cc > #include > int main() { > const double d = 42.0; > return isnan(d) ? 1 : 0; > } > > % clang++ isnan.cc > isnan.cc:4:10: error: controlling expression type 'const double' not > compatible with any generic association type > return isnan(d) ? 1 : 0; > ^~~~~~~~ > /usr/include/math.h:109:2: note: expanded from macro 'isnan' > __fp_type_select(x, __inline_isnanf, __inline_isnan, > __inline_isnanl) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > /usr/include/math.h:86:49: note: expanded from macro '__fp_type_select' > #define __fp_type_select(x, f, d, ld) _Generic((0,(x)), > \ > ^~~~~ > 1 error generated. > In the first place C++ code should be using cmath instead of math.h. That said, this is a result of just an another wonderful little difference between C and C++. C standard explicitly states that comma operator does not yield an lvalue but in C++ it can if the right most operand is an lvalue. If C++ compatibility is desired then unary + operator (e.g. _Generic(+(x),...) could be used for the same effect, only downside with this is that the integer arguments are promoted, but that doesn't matter in this case. Pasi