Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jun 2021 18:45:58 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 450f3e55bdad - stable/13 - Work around bogus old gcc "initializer element is not constant" error
Message-ID:  <202106251845.15PIjwji093265@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=450f3e55bdad40578c58653134408b7bc451b8b9

commit 450f3e55bdad40578c58653134408b7bc451b8b9
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-06-25 18:42:38 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-06-25 18:45:36 +0000

    Work around bogus old gcc "initializer element is not constant" error
    
    After df3b437c1e073eb83e9a93af1c417f3ee8d0de3b, older gcc's such as
    4.2.1 (still used on earlier branches for e.g. mips and powerpc) and
    6.3.0 (still used for some cross-builds) started throwing bogus errors
    like:
    
    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.
    
    Work around the error by reusing the (type)DTYPE_MIN and (type)DTYPE_MAX
    macros, so I can MFC this right away, unbreaking a few stable builds.
    
    (cherry picked from commit 0bcd49c13ada1461bcea85e0466811ddcb290b5e)
---
 lib/msun/src/s_lround.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/msun/src/s_lround.c b/lib/msun/src/s_lround.c
index c4d305401ac8..1dd8e697f703 100644
--- a/lib/msun/src/s_lround.c
+++ b/lib/msun/src/s_lround.c
@@ -51,8 +51,8 @@ __FBSDID("$FreeBSD$");
  */
 static const type type_min = (type)DTYPE_MIN;
 static const type type_max = (type)DTYPE_MAX;
-static const type dtype_min = type_min - 0.5;
-static const type dtype_max = type_max + 0.5;
+static const type dtype_min = (type)DTYPE_MIN - 0.5;
+static const type dtype_max = (type)DTYPE_MAX + 0.5;
 #define	INRANGE(x)	(dtype_max - type_max != 0.5 || \
 			 ((x) > dtype_min && (x) < dtype_max))
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106251845.15PIjwji093265>