emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110953: Improve static checking of i


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110953: Improve static checking of integer overflow and stack smashing.
Date: Mon, 19 Nov 2012 15:39:28 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110953
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Mon 2012-11-19 15:39:28 -0800
message:
  Improve static checking of integer overflow and stack smashing.
  
  * configure.ac (WARN_CFLAGS): Add -Wstack-protector and
  -Wstrict-overflow if using GCC 4.7.2 or later on a platform with
  at least 64-bit long int.  This improves static checking on these
  platforms, when configured with --enable-gcc-warnings.
modified:
  ChangeLog
  configure.ac
=== modified file 'ChangeLog'
--- a/ChangeLog 2012-11-17 22:12:47 +0000
+++ b/ChangeLog 2012-11-19 23:39:28 +0000
@@ -1,3 +1,11 @@
+2012-11-19  Paul Eggert  <address@hidden>
+
+       Improve static checking of integer overflow and stack smashing.
+       * configure.ac (WARN_CFLAGS): Add -Wstack-protector and
+       -Wstrict-overflow if using GCC 4.7.2 or later on a platform with
+       at least 64-bit long int.  This improves static checking on these
+       platforms, when configured with --enable-gcc-warnings.
+
 2012-11-17  Paul Eggert  <address@hidden>
 
        Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881).

=== modified file 'configure.ac'
--- a/configure.ac      2012-11-17 22:12:47 +0000
+++ b/configure.ac      2012-11-19 23:39:28 +0000
@@ -717,11 +717,24 @@
   # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
   nw="$nw -Wshadow"
 
-  # The following lines should be removable at some point.
-  nw="$nw -Wstack-protector"
-  nw="$nw -Wstrict-overflow"
+  # The following line should be removable at some point.
   nw="$nw -Wsuggest-attribute=pure"
 
+  AC_MSG_CHECKING([whether to use -Wstack-protector -Wstrict-overflow])
+  AC_PREPROC_IFELSE(
+    [AC_LANG_PROGRAM(
+       [[#if (1 <= __LONG_MAX__ >> 31 >> 31 \
+           && 4 < __GNUC__ + (7 < __GNUC_MINOR__ + (2 <= __GNUC_PATCHLEVEL__)))
+          /* OK */
+         #else
+          #error "Not GCC, or GCC before 4.7.2, or 'long int' has < 64 bits."
+        #endif
+       ]])],
+    [AC_MSG_RESULT(yes)],
+    [AC_MSG_RESULT(no)
+     nw="$nw -Wstack-protector"
+     nw="$nw -Wstrict-overflow"])
+
   gl_MANYWARN_ALL_GCC([ws])
   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
   for w in $ws; do


reply via email to

[Prev in Thread] Current Thread [Next in Thread]