Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Aug 2017 23:32:07 -0700
From:      Mark Millard <markmi@dsl-only.net>
To:        imp@FreeBSD.org, svn-src-head@freebsd.org, FreeBSD Current <freebsd-current@freebsd.org>, FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>, freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: svn commit: r322875 - head/sys/dev/nvme
Message-ID:  <1C5A448F-C91A-4599-8500-E4E46E6F5205@dsl-only.net>

next in thread | raw e-mail | index | archive | help
> Author: imp
> Date: Fri Aug 25 04:33:06 2017
> New Revision: 322875
> URL:=20
> https://svnweb.freebsd.org/changeset/base/322875
>=20
>=20
> Log:
>   Use _Static_assert
>  =20
>   These files are compiled in userland too, so we can't use =
sys/systm.h
>   and rely on CTASSERT. Switch to using _Static_assert instead.
>  =20
>   MFC After: 3 days
>   Sponsored by: Netflix
>=20
> Modified:
>   head/sys/dev/nvme/nvme.h
>   head/sys/dev/nvme/nvme_util.c

As I remember _Static_assert is from C11, not
the older C99.

As I understand head/sys/dev/nvme/nvme.h use by
C++ code could now reject attempts to use
_Static_assert .

There have been at least one old bugzilla report
for such. An example is 205453 (back around
2015-Dec).

=46rom back then:

> # more main.cc
> #include "/usr/include/sys/cdefs.h"
> _Static_assert(1,"Test");
> int main(void)
> {
>     return 0;
> }
>=20
> For example:
>=20
> # g++49 main.cc
> main.cc:2:15: error: expected constructor, destructor, or type =
conversion before '(' token
>  _Static_assert(1,"Test");
> . . .
> g++49, g++5, and powerpc64-portbld-freebsd11.0-g++ all reject the =
above source the same way that libcxxrt/guard.cc compiles are rejected =
during powerpc64-portbld-freebsd11.0-g++ based buildworld lib32 -m32 =
compiles.=20
>=20
> gcc49, gcc5, and powerpc64-portbld-freebsd11.0-gcc all accept the =
above instead (when in main.c instead of main.cc so it is handle as C =
code), with or without the include. _Static_assert is specific to C11 =
and is not part of C++. It takes explicit definitions to make the syntax =
acceptable as C++.
>=20
> Note: clang++ (3.7) accepts the use of the C11 _Static_assert, with or =
without the include, going well outside the C++ language definition.
>=20
> . . .
>=20
> Fixed in r297299 .

(The context was a C++ file head/contrib/libcxxrt/guard.cc so C++'s
static_assert was used instead and -std=3Dc++11 was added for the
library in question [libcxxrt].)

Unless head/sys/dev/nvme/nvme.h is not to be used from
C++ code: use of _Static_assert in the header would appear
to be a problem.

=3D=3D=3D
Mark Millard
markmi at dsl-only.net




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1C5A448F-C91A-4599-8500-E4E46E6F5205>