From owner-freebsd-stable@freebsd.org Fri Aug 25 07:46:55 2017 Return-Path: Delivered-To: freebsd-stable@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 65943DF2322 for ; Fri, 25 Aug 2017 07:46:55 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-210-57.reflexion.net [208.70.210.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1525B77579 for ; Fri, 25 Aug 2017 07:46:54 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 12998 invoked from network); 25 Aug 2017 07:52:01 -0000 Received: from unknown (HELO rtc-sm-01.app.dca.reflexion.local) (10.81.150.1) by 0 (rfx-qmail) with SMTP; 25 Aug 2017 07:52:01 -0000 Received: by rtc-sm-01.app.dca.reflexion.local (Reflexion email security v8.40.2) with SMTP; Fri, 25 Aug 2017 03:46:53 -0400 (EDT) Received: (qmail 18096 invoked from network); 25 Aug 2017 07:46:53 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (AES256-SHA encrypted) SMTP; 25 Aug 2017 07:46:53 -0000 Received: from [192.168.1.109] (c-67-170-167-181.hsd1.or.comcast.net [67.170.167.181]) by iron2.pdx.net (Postfix) with ESMTPSA id E0223EC901F; Fri, 25 Aug 2017 00:46:51 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r322875 - head/sys/dev/nvme From: Mark Millard In-Reply-To: Date: Fri, 25 Aug 2017 00:46:50 -0700 Cc: imp@FreeBSD.org, svn-src-head@freebsd.org, FreeBSD Current , FreeBSD-STABLE Mailing List , freebsd-hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: <1C5A448F-C91A-4599-8500-E4E46E6F5205@dsl-only.net> To: David Chisnall X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2017 07:46:55 -0000 On 2017-Aug-25, at 12:14 AM, David Chisnall = wrote: > On 25 Aug 2017, at 07:32, Mark Millard wrote: >>=20 >> As I remember _Static_assert is from C11, not >> the older C99. >=20 > In pre-C11 dialects of C, _Static_assert is an identifier reserved for = the implementation. sys/cdefs.h defines it to generate a zero-length = array if the condition is true or a negative-length array if it is = false, emulating the behaviour (though giving less helpful error = messages) >=20 >>=20 >> As I understand head/sys/dev/nvme/nvme.h use by >> C++ code could now reject attempts to use >> _Static_assert . >=20 > In C++, _Static_assert is an identifier reserved for the = implementation, but in C++11 or newer static_assert is a keyword. = sys/cdefs.h defines _Static_assert to static_assert for newer versions = of C++ and defines it to the C-before-11-compatible version for = C++-before-11. >=20 > TL;DR: We have gone to a lot of effort to ensure that these keywords = work in all C/C++ dialects, please use them, please report bugs if you = find a case where they don=E2=80=99t work. It appears that at least 11.1-STABLE -r322807 does not handle -std=3Dc++98 styles of use of _Static_assert for g++7 in that g++7 reports an error: # uname -apKU FreeBSD hzFreeBSD11S 11.1-STABLE FreeBSD 11.1-STABLE r322807 amd64 = amd64 1101501 1101501 # more main.cc #include "/usr/include/sys/cdefs.h" _Static_assert(1,"Test"); int main(void) { return 0; } # g++7 -std=3Dc++98 main.cc main.cc:2:15: error: expected constructor, destructor, or type = conversion before '(' token _Static_assert(1,"Test"); ^ So it appears that as stands the _Static_assert implementation requires a more modern C++ standard vintage. With the likes of -Wpedantic clang++ from 11.1-STABLE -r322807 reports a warning: # clang++ -Wpedantic -std=3Dc++11 main.cc main.cc:2:1: warning: _Static_assert is a C11-specific feature = [-Wc11-extensions] _Static_assert(1,"Test"); ^ 1 warning generated. # clang++ -Wpedantic -std=3Dc++98 main.cc In file included from main.cc:1: /usr/include/sys/cdefs.h:852:27: warning: variadic macros are a C99 = feature [-Wvariadic-macros] #define __locks_exclusive(...) \ ^ . . . (more such macro reports) . . . main.cc:2:1: warning: _Static_assert is a C11-specific feature = [-Wc11-extensions] _Static_assert(1,"Test"); ^ 11 warnings generated. By contrast "g++7 -Wpedantic -std=3Dc++11 main.cc" is silent about it. =3D=3D=3D Mark Millard markmi at dsl-only.net