ping i'd like to see this change go in asap since it is pre-requisite to turning on -Wvla which explicitly caught use of non-constant expressions in the RTE_BUILD_BUG_ON() hiding bugs.
thanks! On Mon, Nov 13, 2023 at 09:06:05AM -0800, Stephen Hemminger wrote: > Both Gcc, clang and MSVC have better way to do compile time > assertions rather than using out of bounds array access. > The old method would fail if -Wvla is enabled because compiler > can't determine size in that code. Also, the use of new > _Static_assert will catch broken code that is passing non-constant > expression to RTE_BUILD_BUG_ON(). > > Signed-off-by: Stephen Hemminger <step...@networkplumber.org> > Acked-by: Morten Brørup <m...@smartsharesystems.com> > Acked-by: Tyler Retzlaff <roret...@linux.microsoft.com> > --- > lib/eal/include/rte_common.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h > index c1ba32d00e47..bea7c0e57d5e 100644 > --- a/lib/eal/include/rte_common.h > +++ b/lib/eal/include/rte_common.h > @@ -16,6 +16,7 @@ > extern "C" { > #endif > > +#include <assert.h> > #include <stdint.h> > #include <limits.h> > > @@ -495,7 +496,7 @@ rte_is_aligned(const void * const __rte_restrict ptr, > const unsigned int align) > /** > * Triggers an error at compilation time if the condition is true. > */ > -#define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) > +#define RTE_BUILD_BUG_ON(condition) static_assert(!(condition), #condition) > > /*********** Cache line related macros ********/ > > -- > 2.39.2