Opened 15 years ago
Closed 15 years ago
#23 closed defect (fixed)
strict-aliasing warnings from gcc 4.4.1 on Linux x86_64
Reported by: | Christian Franke | Owned by: | somebody |
---|---|---|---|
Priority: | minor | Milestone: | Experimental Release 5.39 |
Component: | all | Version: | |
Keywords: | Cc: | manfred99 |
Description
Build from smartmontools-5.39-rc.tar.gz (r2990) with gcc 4.4.1:
g++ [...] -g -O2 -Wall -W [...] -c -o os_linux.o os_linux.cpp
os_linux.cpp: In member function 'bool os_linux::linux_megaraid_device::megasas_cmd(int, void*, int, void*, int, void*, int)':
os_linux.cpp:1108: warning: dereferencing pointer 'pthru' does break strict-aliasing rules
[...]
os_linux.cpp:1079: warning: dereferencing pointer 'pthru' does break strict-aliasing rules
os_linux.cpp:1078: note: initialized from here
Change History (2)
follow-up: 2 comment:1 by , 15 years ago
comment:2 by , 15 years ago
Milestone: | RC1 5.40 → Experimental Release 5.39 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
r2992.
Option '-fno-strict-aliasing' set if supported. Patch slightly enhanced such that this can be overridden with CXXFLAGS='-fstrict-aliasing' configure argument.
how about just disabling aliasing optimization?
Smartmontools is not an high performance application, after all.
Something like:
--- configure.in (Revision 2990)
+++ configure.in (Arbeitskopie)
@@ -310,7 +310,7 @@
-dnl Add -Wall and -W if using gcc and its not already specified.
+dnl Add -Wall and -W if using g++ and its not already specified.
@@ -319,6 +319,18 @@
+ ac_save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="-fno-strict-aliasing"
+ AC_MSG_CHECKING([whether g++ supports -fno-strict-aliasing])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [gcc_have_fno_strict_aliasing=yes], [gcc_have_fno_strict_aliasing=no])
+ AC_MSG_RESULT([$gcc_have_fno_strict_aliasing])
+ AC_SUBST(gcc_have_fno_strict_aliasing)
+ if test "$gcc_have_fno_strict_aliasing" = "yes"; then
+ CXXFLAGS="$ac_save_CXXFLAGS -fno-strict-aliasing"
+ else
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ fi