bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fixed tests build on EDG-based compilers


From: Bruno Haible
Subject: Re: [PATCH] Fixed tests build on EDG-based compilers
Date: Mon, 06 Dec 2021 16:31:39 +0100

Илья Курдюков wrote:
> To reproduce the issue, try this as C code using ICC 19.0.1 in Compiler 
> Explorer:
> 
> #ifdef __GNUC__
> _Static_assert(__builtin_add_overflow_p (0x7fffffff, 1, 0), "");
> #endif
> 
> Compiler output:
> 
> <source>(2): error: expression must be an integral constant expression
>    _Static_assert(__builtin_add_overflow_p (0x7fffffff, 1, 0), "");
>                   ^
> 
> <source>(2): error: function call is not allowed in a constant expression
>    _Static_assert(__builtin_add_overflow_p (0x7fffffff, 1, 0), "");
>                   ^

Thanks. For Intel cc, we already have a workaround in intprops.h. Can you
confirm that with your EDG-based LCC, you get the same error for this case?

If so, I think the right fix will be this one (proposed patch):


2021-12-05  Bruno Haible  <bruno@clisp.org>

        intprops: Treat EDG-based compilers like Intel compilers.
        Reported by Ilya Kurdyukov <ilyakurdyukov@altlinux.org> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2021-12/msg00025.html>.
        * lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW_P): Define to 0 on EDG-based
        compilers.

diff --git a/lib/intprops.h b/lib/intprops.h
index 3fe64e82e..b36e0bbed 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -249,11 +249,12 @@
 
 /* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
    __builtin_sub_overflow_p and __builtin_mul_overflow_p.  */
-#if defined __clang__ || defined __ICC
+#if defined __clang__ || defined __ICC || defined __EDG__
 /* Clang 11 lacks __builtin_mul_overflow_p, and even if it did it
-   would presumably run afoul of Clang bug 16404.  ICC 2021.1's
-   __builtin_add_overflow_p etc. are not treated as integral constant
-   expressions even when all arguments are.  */
+   would presumably run afoul of Clang bug 16404.  In ICC 2021.1 and
+   the EDG-based MCST Elbrus LCC compiler, __builtin_add_overflow_p etc.
+   are not treated as integral constant expressions even when all
+   arguments are.  */
 # define _GL_HAS_BUILTIN_OVERFLOW_P 0
 #elif defined __has_builtin
 # define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]