[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] build: with --enable-gcc-warnings avoid unwarranted failure w/gc
From: |
Jim Meyering |
Subject: |
[PATCH] build: with --enable-gcc-warnings avoid unwarranted failure w/gcc-4.6.1 |
Date: |
Mon, 12 Sep 2011 15:13:05 +0200 |
Building coreutils on fedora rawhide (using --enable-gcc-warnings),
I was annoyed one too many times by failure to compile due to this
bogus warning from "gcc version 4.6.1 20110824 (Red Hat 4.6.1-8) (GCC)":
test.c:95:1: error: function might be candidate for attribute 'pure' if it \
is known to return normally [-Werror=suggest-attribute=pure]
cc1: all warnings being treated as errors
I filed a bug about this months ago, and it's been fixed in 4.7 for
some time, but since rawhide is still using 4.6.1, ...
I want to --enable-gcc-warnings and have been using gcc-built-from-trunk
on my F15 desktop for precisely this reason, but refuse to build gcc from
sources everywhere just to get by this problem.
>From 419c9067271982df2299d4db378e9eac6ea13889 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 12 Sep 2011 15:04:32 +0200
Subject: [PATCH] build: with --enable-gcc-warnings avoid unwarranted failure
w/gcc-4.6.1
* configure.ac (WERROR_CFLAGS): With --enable-gcc-warnings, use
-Wsuggest-attribute=pure only only with gcc 4.7 or newer.
---
configure.ac | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 291b19e..2a9ed81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,9 +102,18 @@ if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wsuggest-attribute=const])
- gl_WARN_ADD([-Wsuggest-attribute=pure])
gl_WARN_ADD([-Wsuggest-attribute=noreturn])
+ # Enable this warning only with gcc-4.7 and newer. With 4.6.1 20110824,
+ # it suggests test.c's advance function may be pure, even though it
+ # increments a global variable. Oops.
+ # Normally we'd write code to test for the precise failure, but that
+ # requires a relatively large input to make gcc exhibit the failure.
+ case `$CC -v` in
+ *'gcc version '4.[0-6]*) ;;
+ *'gcc version '[4-9]*) gl_WARN_ADD([-Wsuggest-attribute=pure]) ;;
+ esac
+
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
gl_WARN_ADD([-Wno-logical-op])
--
1.7.7.rc0.362.g5a14
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] build: with --enable-gcc-warnings avoid unwarranted failure w/gcc-4.6.1,
Jim Meyering <=