bug 1868: enable -Wstrict-overflow only for newer gcc versions
authorTom Henderson <tomh@tomh.org>
Wed, 28 May 2014 23:03:23 -0700
changeset 10790 b445436fd51f
parent 10789 e3ab7abd6f63
child 10791 9b29bb9d495b
bug 1868: enable -Wstrict-overflow only for newer gcc versions
wscript
--- a/wscript	Wed May 28 13:10:59 2014 -0700
+++ b/wscript	Wed May 28 23:03:23 2014 -0700
@@ -29,6 +29,10 @@
 examples_enabled = False
 tests_enabled    = False
 
+# Bug 1868:  be conservative about -Wstrict-overflow for optimized builds
+# on older compilers; it can generate spurious warnings.  
+min_cc_version_warn_strict_overflow = ('4', '8', '2')
+
 # Get the information out of the NS-3 configuration file.
 config_file_exists = False
 (config_file_exists, modules_enabled, examples_enabled, tests_enabled) = read_config_file()
@@ -326,7 +330,8 @@
             if conf.check_compilation_flag('-march=native'):
                 env.append_value('CXXFLAGS', '-march=native') 
             env.append_value('CXXFLAGS', '-fstrict-overflow')
-            env.append_value('CXXFLAGS', '-Wstrict-overflow=5')
+            if conf.env['CC_VERSION'] >= min_cc_version_warn_strict_overflow:
+                env.append_value('CXXFLAGS', '-Wstrict-overflow=5')
 
         if sys.platform == 'win32':
             env.append_value("LINKFLAGS", "-Wl,--enable-runtime-pseudo-reloc")