From: Nicola Vetrini <nicola.vetrini@gmail.com>
The toolchain baseline for GCC is 5.1, which supports _Static_assert
in c99 mode
No functional change.
Signed-off-by: Nicola Vetrini <nicola.vetrini@gmail.com>
---
Mentioned in https://gitlab.com/xen-project/xen/-/issues/201
---
xen/include/xen/macros.h | 8 --------
1 file changed, 8 deletions(-)
diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h
index cd528fbdb127..f9ccde86fb23 100644
--- a/xen/include/xen/macros.h
+++ b/xen/include/xen/macros.h
@@ -40,9 +40,6 @@
#ifndef __ASSEMBLY__
-/* All clang versions supported by Xen have _Static_assert. */
-#if defined(__clang__) || \
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
/* Force a compilation error if condition is true */
#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })
@@ -54,11 +51,6 @@
*/
#define BUILD_BUG_ON_ZERO(cond) \
(sizeof(struct { char c; _Static_assert(!(cond), "!(" #cond ")"); }) & 0)
-#else
-#define BUILD_BUG_ON_ZERO(cond) \
- (sizeof(struct { unsigned u : !(cond); }) & 0)
-#define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))
-#endif
/*
* Force a compilation error. This is for code which, in the normal case,
--
2.43.0
On 13.08.2025 21:12, nicola.vetrini@gmail.com wrote: > From: Nicola Vetrini <nicola.vetrini@gmail.com> > > The toolchain baseline for GCC is 5.1, which supports _Static_assert > in c99 mode Hmm, interesting. I can confirm the behavior, but isn't this a bug? There's no _Static_assert() in plain C99. Respective notes in the "Changes, New Features, and Fixes" are also saying otherwise: https://gcc.gnu.org/gcc-4.6/changes.html has "This support may be selected with -std=c1x, or -std=gnu1x for C1X with GNU extensions." Nothing new is said in any of the respective documents up to the release of gcc5. (In fact, the compiler accepts the construct even with -std=c89.) Our misra/C-language-toolchain.rst refers to a section in gcc12's doc which doesn't mention _Static_assert() at all, afaics. Jan
On Thu, Aug 14, 2025, 10:08 Jan Beulich <jbeulich@suse.com> wrote: > On 13.08.2025 21:12, nicola.vetrini@gmail.com wrote: > > From: Nicola Vetrini <nicola.vetrini@gmail.com> > > > > The toolchain baseline for GCC is 5.1, which supports _Static_assert > > in c99 mode > > Hmm, interesting. I can confirm the behavior, but isn't this a bug? > There's no > _Static_assert() in plain C99. Respective notes in the "Changes, New > Features, > and Fixes" are also saying otherwise: > https://gcc.gnu.org/gcc-4.6/changes.html > has "This support may be selected with -std=c1x, or -std=gnu1x for C1X with > GNU extensions." Nothing new is said in any of the respective documents up > to > the release of gcc5. (In fact, the compiler accepts the construct even with > -std=c89.) > Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes. Use of the -std options listed above disables these extensions where they conflict with the C standard version selected If my reading is correct then this paragraph gives them the leeway needed to use it even in c89, except maybe with -pedantic > Our misra/C-language-toolchain.rst refers to a section in gcc12's doc which > doesn't mention _Static_assert() at all, afaics. > > Jan > I can check with my colleagues, but I suspect this is not documented as an extension by GCC because it's not one in C11, and gcc12 supports all(?) of C11, therefore it is an extension only with respect to certain conditions, which GCC does not use as a category in their docs, but we keep track of what is an extension and what is not, given the CU standard selected. >
On 13/08/2025 8:12 pm, nicola.vetrini@gmail.com wrote: > From: Nicola Vetrini <nicola.vetrini@gmail.com> > > The toolchain baseline for GCC is 5.1, which supports _Static_assert > in c99 mode > > No functional change. > > Signed-off-by: Nicola Vetrini <nicola.vetrini@gmail.com> > --- > Mentioned in https://gitlab.com/xen-project/xen/-/issues/201 Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
© 2016 - 2025 Red Hat, Inc.