diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index 9106eb2f982f64fc974cce28197ca2241ac2b9fd..44c12131f52072fe80730e745694b05dca5d56d5 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,11 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] configure.in: Add '-fno-strict-aliasing' to CXXFLAGS if supported.
+       This suppresses gcc 4.4.1 warnings on Linux and avoids possible
+       unsafe optimizations (ticket #23).
+       Patch was provided by Manfred Schwarb.
+
   [CF] Avoid truncation of configure arguments in '-V' output.
 
   [AS] Added USB IDs of WD Passport USB Portable
diff --git a/smartmontools/configure.in b/smartmontools/configure.in
index e33fa827e8949e5194d8ef0d751496db8a64a782..b0d9056fbc70db012a6a61240e778960163f48b0 100644
--- a/smartmontools/configure.in
+++ b/smartmontools/configure.in
@@ -310,8 +310,8 @@ AM_CONDITIONAL(OS_SOLARIS, [echo $host_os | grep '^solaris' > /dev/null])
 AM_CONDITIONAL(OS_WIN32_MINGW, [echo $host_os | grep '^mingw' > /dev/null])
 AM_CONDITIONAL(OS_FREEBSD, [echo $host_os | grep '^freebsd' > /dev/null])
 
-dnl Add -Wall and -W if using gcc and its not already specified.
-if test "x$GCC" = "xyes"; then
+dnl Add -Wall and -W if using g++ and its not already specified.
+if test "$GXX" = "yes"; then
   if test -z "`echo "$CXXFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
       CXXFLAGS="$CXXFLAGS -Wall"
   fi
@@ -324,6 +324,21 @@ if test "x$GCC" = "xyes"; then
       # MinGW uses MSVCRT.DLL which uses printf format "%I64d" and not "%lld" for int64_t
       CXXFLAGS="$CXXFLAGS -Wno-format";;
   esac
+
+  # Disable strict aliasing rules by default (see ticket #23).
+  if test -z "`echo "$CXXFLAGS" | grep "\-f[[no-]]*strict-aliasing" 2> /dev/null`" ; then
+    AC_MSG_CHECKING([whether g++ supports -fno-strict-aliasing])
+    ac_save_CXXFLAGS="$CXXFLAGS"
+    CXXFLAGS="-fno-strict-aliasing"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+      [gcc_have_fno_strict_aliasing=yes], [gcc_have_fno_strict_aliasing=no])
+    CXXFLAGS="$ac_save_CXXFLAGS"
+    if test "$gcc_have_fno_strict_aliasing" = "yes"; then
+      CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+    fi
+    AC_MSG_RESULT([$gcc_have_fno_strict_aliasing])
+  fi
+
 else
  dnl We are NOT using gcc, so enable host-specific compiler flags
  case "${host}" in