From owner-freebsd-ports@freebsd.org Thu May 12 18:00:08 2016 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4264CB38F43 for ; Thu, 12 May 2016 18:00:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 2D8EB1B45 for ; Thu, 12 May 2016 18:00:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: by mailman.ysv.freebsd.org (Postfix) id 29226B38F40; Thu, 12 May 2016 18:00:08 +0000 (UTC) Delivered-To: ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28CA7B38F3F for ; Thu, 12 May 2016 18:00:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E4F351B43 for ; Thu, 12 May 2016 18:00:07 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:7b8:3a7::98f7:82fc:afc5:9bc3] (unknown [IPv6:2001:7b8:3a7:0:98f7:82fc:afc5:9bc3]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 096B031AF0; Thu, 12 May 2016 19:59:59 +0200 (CEST) Subject: Re: Why clang++37 behaves differently on 9.3 and 10.3? Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: multipart/signed; boundary="Apple-Mail=_C7A2D3F8-C489-4E4F-9046-745DF68D67FB"; protocol="application/pgp-signature"; micalg=pgp-sha1 X-Pgp-Agent: GPGMail 2.6b2 (ebbf3ef) From: Dimitry Andric In-Reply-To: <57346A14.6010402@rawbw.com> Date: Thu, 12 May 2016 19:59:43 +0200 Cc: "ports@freebsd.org" Message-Id: References: <57346A14.6010402@rawbw.com> To: Yuri X-Mailer: Apple Mail (2.3124) X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2016 18:00:08 -0000 --Apple-Mail=_C7A2D3F8-C489-4E4F-9046-745DF68D67FB Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 12 May 2016, at 13:33, Yuri wrote: > > clang++37 compiles this simple program fine on 10.3, but fails on 9.3. > > Why does it behave differently on different OS versions? > > It looks like it ignores -std=c++11 on 9.3. You cannot compile for C++11 on a 9.x installation, because clang will use libstdc++ by default there, and the version of libstdc++ in the 9.x base system is not C++11 compatible. To be able to use C++11, you must install libc++ first, using for example: export CC=clang export CXX=clang++ cd /usr/src/lib/libcxxrt make obj make depend make make install cd /usr/src/lib/libc++ make obj make depend make make install Alternatively, rebuild world with these settings in /etc/src.conf: WITH_CLANG_IS_CC=y WITH_LIBCPLUSPLUS=y On FreeBSD 10.x, clang and libc++ are the defaults, and C++11 can be used out of the box. > test.cc:6:17: note: initializer of 'vmax' is not a constant expression > test.cc:5:13: note: declared here > const int vmax = std::numeric_limits::max(); > ^ This is because libstdc++ defines numeric_limits::max() as follows: template<> struct numeric_limits { ... static int max() throw() { return __INT_MAX__; } While max() appears to be pretty constant in its return value, it is not defined constexpr, and therefore you cannot use it in a static assert. Note that later versions of libstdc++ do use constexpr when appropriate: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=166171 -Dimitry --Apple-Mail=_C7A2D3F8-C489-4E4F-9046-745DF68D67FB Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlc0xJ4ACgkQsF6jCi4glqOMngCg8wS9o9nJZQHyvRhE2nRz52h8 L+IAoOs+3DIozpZksgxUnQBeKZzYeslC =KtQg -----END PGP SIGNATURE----- --Apple-Mail=_C7A2D3F8-C489-4E4F-9046-745DF68D67FB--