build: disable GCC string op warnings when unoptimized
PATCH 1/2 build: disable GCC string op warnings when unoptimized
Without optimization GCC produces warnings for unreachable code paths. They check memcpy() against the object size even on paths that are dead for the inlined arguments. This breaks debug builds of app/test with -Werror on lib/stack/rte_stack_pile.h,
and has required local pragma workarounds elsewhere.
Disable both warnings when optimization is 0. They stay enabled for optimized builds, where the analysis is flow-sensitive.
Bugzilla ID: 2061
--- config/meson.build | 6 ++++++ 1 file changed, 6 insertions(+)
config/meson.build +6 -0
@@ -378,6 +378,12 @@ if cc.has_argument('-Wno-comma') no_comma_cflag = '-Wno-comma' endif +# GCC's string/memory access warnings are flow-insensitive without +# optimization and produce false positives on dead paths of inlined code. +if get_option('optimization') == '0' and cc.get_id() == 'gcc' + global_cflags += ['-Wno-stringop-overflow', '-Wno-stringop-overread'] +endif + foreach arg: global_cflags if cc.has_argument(arg) add_project_arguments(arg, language: 'c')
Signature · 1 line
2.53.0
PATCH 2/2 ring: remove GCC pragma
The original issue that required using pragma here to disable stringop warnings is now handled at in config/meson.build across all files.
--- lib/ring/rte_ring_elem_pvt.h | 10 ---------- 1 file changed, 10 deletions(-)
lib/ring/rte_ring_elem_pvt.h +0 -10
@@ -10,12 +10,6 @@#ifndef _RTE_RING_ELEM_PVT_H_#define _RTE_RING_ELEM_PVT_H_ -#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=120000 ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-overflow" -#pragma GCC diagnostic ignored "-Wstringop-overread" -#endif - static __rte_always_inline void__rte_ring_enqueue_elems_32 (void *ring_table,const void *obj_table,uint32_t size,uint32_t idx,uint32_t n)
@@ -500,8 +494,4 @@ __rte_ring_do_dequeue_elem(struct rte_ring *r, void *obj_table, return n; } -#if defined(RTE_TOOLCHAIN_GCC ) && (GCC_VERSION >=120000 ) -#pragma GCC diagnostic pop -#endif -#endif /* _RTE_RING_ELEM_PVT_H_ */
Signature · 1 line
2.53.0
Quoted 40 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 20 October 2026 16.56Without optimization GCC produces warnings for unreachable code paths. They check
memcpy()against the object size even on paths that are dead for the inlined arguments. This breaks debug builds of app/test with -Werror onlib/stack/rte_stack_pile.h,
and has required local pragma workarounds elsewhere.Disable both warnings when optimization is 0. They stay enabled for optimized builds, where the analysis is flow-sensitive.
Bugzilla ID: 2061
Reported-by Ali Alnubani <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>--- config/meson.build | 6 ++++++ 1 file changed, 6 insertions(+)config/meson.build +2
-0@@ -378,6 +378,12 @@ if cc.has_argument('-Wno-comma') no_comma_cflag = '-Wno-comma' endif +# GCC's string/memory access warnings are flow-insensitive without +# optimization and produce false positives on dead paths of inlinedcode.
config/meson.build +2
-0+if get_option('optimization') == '0' and cc.get_id() == 'gcc' + global_cflags += ['-Wno-stringop-overflow', '-Wno-stringop-overread']
config/meson.build +2
-1+endif + foreach arg: global_cflags if cc.has_argument(arg) add_project_arguments(arg, language: 'c') --
Quoted 1 line
2.53.0
I replied in the wrong thread, here it comes again:
Also '-Warray-bounds'?
Consider making it a series, and also remove existing overflow/overread pragmas in the code (if viable):lib/ring/rte_ring_elem_pvt.h - You did this already!lib/eal/ppc/include/rte_memcpy.h
With or without suggested changes,
Quoted 3 lines · On Tue, 20 Oct 2026 17:33:32 +0200 Morten Brørup <[email protected]>…
I replied in the wrong thread, here it comes again:
Also '-Warray-bounds'?
No, if it doesn't trip today, then no need to change.
Quoted 5 lines
Consider making it a series, and also remove existing overflow/overread pragmas in the code (if viable):
lib/ring/rte_ring_elem_pvt.h- You did this already!
lib/eal/ppc/include/rte_memcpy.h
PPC rte_memcpy is doing something different and likely because of different versions of GCC.
Not sure in general how supported ppc is so left it alone.
Quoted 2 lines
With or without suggested changes,
Quoted 7 lines · Stephen Hemminger
Without optimization GCC produces warnings for unreachable code paths. They check
memcpy()against the object size even on paths that are dead for the inlined arguments. This breaks debug builds of app/test with -Werror onlib/stack/rte_stack_pile.h,
and has required local pragma workarounds elsewhere.
Quoted 8 lines
Disable both warnings when optimization is 0. They stay enabled for optimized builds, where the analysis is flow-sensitive.
Bugzilla ID: 2061
Reported-by Ali Alnubani <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>Acked-by Morten Brørup <[email protected]>
Series applied, thanks.
Signature · 1 line
David Marchand