_Static_assert needs two arguments for compatibility with GCC before 9

Message ID 87r1e0s7ob.fsf@oldenburg.str.redhat.com
State Committed
Commit c9fef4b7d1d0f2dad192c74f06102752247677a9
Headers
Series _Static_assert needs two arguments for compatibility with GCC before 9 |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Florian Weimer Sept. 7, 2021, 3:54 p.m. UTC
  This macro definition enforces two arguments even with newer compilers
that accept the single-argument form, too.

Tested on i686-linux-gnu, x86_64-linux-gnu.  Built with
build-many-glibcs.py.

---
 include/sys/cdefs.h | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Carlos O'Donell Sept. 8, 2021, 2:52 p.m. UTC | #1
On 9/7/21 11:54 AM, Florian Weimer via Libc-alpha wrote:
> This macro definition enforces two arguments even with newer compilers
> that accept the single-argument form, too.
> 
> Tested on i686-linux-gnu, x86_64-linux-gnu.  Built with
> build-many-glibcs.py.

Thanks for preventing this from happening again :-)

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  include/sys/cdefs.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
> index 6a76160ed4..56adb231aa 100644
> --- a/include/sys/cdefs.h
> +++ b/include/sys/cdefs.h
> @@ -1,5 +1,12 @@
>  #ifndef _SYS_CDEFS_H
>  
> +/* This is outside of _ISOMAC to enforce that _Static_assert always
> +   uses the two-argument form.  This can be removed once the minimum
> +   GCC version used to compile glibc is GCC 9.1.  */
> +#ifndef __cplusplus
> +# define _Static_assert(expr, diagnostic) _Static_assert (expr, diagnostic)
> +#endif
> +
>  #include <misc/sys/cdefs.h>
>  
>  #ifndef _ISOMAC
>
  

Patch

diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index 6a76160ed4..56adb231aa 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -1,5 +1,12 @@ 
 #ifndef _SYS_CDEFS_H
 
+/* This is outside of _ISOMAC to enforce that _Static_assert always
+   uses the two-argument form.  This can be removed once the minimum
+   GCC version used to compile glibc is GCC 9.1.  */
+#ifndef __cplusplus
+# define _Static_assert(expr, diagnostic) _Static_assert (expr, diagnostic)
+#endif
+
 #include <misc/sys/cdefs.h>
 
 #ifndef _ISOMAC