multipath-tools uses container_of() and similar macros, which imply
casts between different types, which isn't stricly compliant with
strict aliasing rules. The issue that lead to the previous commit
"libmpathutil: use union for bitfield" was one example where this
can fail. While that one could be fixed relatively easily, it shows
that surprises can happen any time when we compile our code with
strict aliasing enabled. This can be seen clearly when we compile
with "-fstrict-aliasing -Wstrict-aliasing=1" (note that the bitfield
problem is only reported by gcc with "-Wstrict-aliasing=1", other
levels of aliasing detection miss it with gcc 15).

Use -fno-strict-aliasing to disable it. The kernel does the same.

Signed-off-by: Martin Wilck <[email protected]>
---
 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index 3dbcdcf..539415d 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -122,7 +122,7 @@ CPPFLAGS    := $(FORTIFY_OPT) $(CPPFLAGS) $(D_URCU_VERSION) 
$(D_CMOCKA_VERSION) \
                   -DWSTRINGOP_TRUNCATION=$(if $(WSTRINGOP_TRUNCATION),1,0) \
                   -MMD -MP
 CFLAGS         := -std=$(C_STD) $(CFLAGS) $(OPTFLAGS) $(WARNFLAGS) -pipe \
-                  -fexceptions
+                  -fexceptions -fno-strict-aliasing
 BIN_CFLAGS     := -fPIE -DPIE
 LIB_CFLAGS     := -fPIC
 SHARED_FLAGS   := -shared
-- 
2.52.0


Reply via email to