https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121811

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #14)
> Andrew, what's the objection to GCC just putting #ifndef __cplusplus in our
> header?
> 
> Do we have to make things harder for people?

Instead of that I'd think it should be
--- gcc/ginclude/stdckdint.h    2025-04-08 14:08:51.778274529 +0200
+++ gcc/ginclude/stdckdint.h    2025-09-06 10:46:43.856898278 +0200
@@ -28,9 +28,15 @@ see the files COPYING3 and COPYING.RUNTI

 #define __STDC_VERSION_STDCKDINT_H__ 202311L

-#define ckd_add(r, a, b) ((_Bool) __builtin_add_overflow (a, b, r))
-#define ckd_sub(r, a, b) ((_Bool) __builtin_sub_overflow (a, b, r))
-#define ckd_mul(r, a, b) ((_Bool) __builtin_mul_overflow (a, b, r))
+#if __STDC_VERSION__ >= 202311L || defined(__cplusplus)
+# define ckd_add(r, a, b) ((bool) __builtin_add_overflow (a, b, r))
+# define ckd_sub(r, a, b) ((bool) __builtin_sub_overflow (a, b, r))
+# define ckd_mul(r, a, b) ((bool) __builtin_mul_overflow (a, b, r))
+#else
+# define ckd_add(r, a, b) ((_Bool) __builtin_add_overflow (a, b, r))
+# define ckd_sub(r, a, b) ((_Bool) __builtin_sub_overflow (a, b, r))
+# define ckd_mul(r, a, b) ((_Bool) __builtin_mul_overflow (a, b, r))
+#endif

 /* Allow for the C library to add its part to the header.  */
 #if !defined (_LIBC_STDCKDINT_H) && __has_include_next (<stdckdint.h>)
The use of _Bool isn't strictly necessary there, the header is C23, but it is
used just to make it usable even in C17/C11/C99 code.

Reply via email to