Date: Fri, 25 Jun 2021 21:11:27 -0700 From: Mark Millard <marklmi@yahoo.com> To: Dimitry Andric <dim@FreeBSD.org>, dev-commits-src-branches@freebsd.org Subject: Re: git: 450f3e55bdad - stable/13 - Work around bogus old gcc "initializer element is not constant" error Message-ID: <87104032-C5B9-447D-9545-B30AF983ACB7@yahoo.com> References: <87104032-C5B9-447D-9545-B30AF983ACB7.ref@yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Dimitry Andric dim at FreeBSD.org wrote on Fri Jun 25 18:46:00 UTC 2021 : . . . > In file included from /workspace/src/lib/msun/src/s_llround.c:11:0: > /workspace/src/lib/msun/src/s_lround.c:54:31: error: initializer = element is not constant > static const type dtype_min =3D type_min - 0.5; > ^~~~~~~~ > /workspace/src/lib/msun/src/s_lround.c:55:31: error: initializer = element is not constant > static const type dtype_max =3D type_max + 0.5; > ^~~~~~~~ > =20 > Since 'type_min' and 'type_max' are constants declared just above = these > lines this error is nonsensical, but older gcc's are not smart = enough. . . . Well, in C "const" historically means closer to "read-only" than to is-a-constant-expression in the language, unfortunately. Part of this is the conversion away from being an lvalue (so: where an lvalue is not required) loses the const qualification as part of the conversion. As: https://en.cppreference.com/w/cpp/language/constexpr words it in the notes: QUOTE C adopted the const qualifier from C++, but unlike in C++, expressions of const-qualified type in C are not constant expressions; they may not be used as case labels or to initialize static and thread storage duration objects, enumerators, or bit field sizes. When they are used as array sizes, the resulting arrays are VLAs. END QUOTE =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87104032-C5B9-447D-9545-B30AF983ACB7>