Hack compiler flags to silence warnings on gcc 4.8
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 20 May 2013 22:13:38 +0000 (00:13 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 21 May 2013 12:13:42 +0000 (14:13 +0200)
GCC changed its default behaviour when reporting a number of different
kinds of warnings. We don't want to fix these in the bugfix branch
because even where it is possible it looks too invasive. We plan to
address these issues in a less heavy-handed manner in master branch.

Note when merging to master, do not include this patch.

Change-Id: I14f00357195424dd538aca4b319e5c2c120c691d

cmake/gmxCFlags.cmake

index 38f9057ee573b8a3ace8bf34e2a5b355a29aa343..1cf5dafe4cb89ce6ad5bc5ac4e20db36737ffe75 100644 (file)
@@ -68,7 +68,16 @@ MACRO(gmx_c_flags)
         if(NOT GMX_OPENMP)
             GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
         endif()
-        GMX_TEST_CFLAG(CFLAGS_WARN "-Wall -Wno-unused -Wunused-value" GMXC_CFLAGS)
+        if (C_COMPILER_VERSION VERSION_EQUAL 4.8 OR C_COMPILER_VERSION VERSION_GREATER 4.8)
+            # In gcc 4.8 the default settings for many warning types
+            # were changed. Fixing many of them in C is at best
+            # awkward, and some of the fixes might require ABI
+            # changes, which we prefer not to do in a bugfix
+            # branch. So we introduce these workarounds, and plan to
+            # addess problems in master branch.
+            set(extra_warn_flags_for_gcc_4_8 " -Wno-unused-parameter -Wno-array-bounds -Wno-maybe-uninitialized -Wno-strict-overflow")
+        endif()
+        GMX_TEST_CFLAG(CFLAGS_WARN "-Wall -Wno-unused -Wunused-value${extra_warn_flags_for_gcc_4_8}" GMXC_CFLAGS)
         GMX_TEST_CFLAG(CFLAGS_WARN_EXTRA "-Wextra -Wno-missing-field-initializers -Wno-sign-compare" GMXC_CFLAGS)
         # new in gcc 4.5
         GMX_TEST_CFLAG(CFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CFLAGS_RELEASE)