Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jun 2021 15:36:54 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        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:  <62DD1D7C-68FA-4931-A219-2C90A97A56A7@FreeBSD.org>
In-Reply-To: <87104032-C5B9-447D-9545-B30AF983ACB7@yahoo.com>
References:  <87104032-C5B9-447D-9545-B30AF983ACB7.ref@yahoo.com> <87104032-C5B9-447D-9545-B30AF983ACB7@yahoo.com>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On 26 Jun 2021, at 06:11, Mark Millard <marklmi@yahoo.com> wrote:
> 
> 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 = 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 = type_max + 0.5;
>>                                   ^~~~~~~~
>> 
>>    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.

FWIW, this changed in gcc 8.1+, here:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=f9c59f7e9511856bd6dc13d2d4904ebd9249c095

referencing these bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66618
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960

In one of the comments, joseph@codesourcery.com mentions:
> Although diagnosing this probably makes sense, it's not required by the
> standard ("An implementation may accept other forms of constant
> expressions." - and this expression doesn't contain "assignment,
> increment, decrement, function-call, or comma operators", so isn't
> required by the Constraints for constant expressions not to be one).

I guess the gcc people also decided that POLA applied here. :)

-Dimitry


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2

iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCYNctdgAKCRCwXqMKLiCW
oyaBAKCIxLTfSv2mK433xEngt8cL7h8RwACfXQSraD/vRSxylfCnPel9wcMtvPw=
=7uA2
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?62DD1D7C-68FA-4931-A219-2C90A97A56A7>