This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pragma change breaks build


David Miller wrote:
instead of just adding a "= 0" initializer to vallen so
that all gcc's will not warn

That could cause glibc to have a useless machine instruction, no?  Horrors!

Does the attached patch work for you?
>From 3e14ca767b43554c34f3f95c64ac793bdbd733fa Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 27 Apr 2015 15:30:43 -0700
Subject: [PATCH] * stdlib/setenv.c: Pacify only GCC 4.7 and later.

Problem with -Wmaybe-uninitialized reported by David Miller in:
https://sourceware.org/ml/libc-alpha/2015-04/msg00345.html
---
 ChangeLog       |  6 ++++++
 stdlib/setenv.c | 14 ++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 39f74cc..706b5e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* stdlib/setenv.c: Pacify only GCC 4.7 and later.
+	Problem with -Wmaybe-uninitialized reported by David Miller in:
+	https://sourceware.org/ml/libc-alpha/2015-04/msg00345.html
+
 2015-04-27  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ#18333]
diff --git a/stdlib/setenv.c b/stdlib/setenv.c
index 184a8cd..ee45458 100644
--- a/stdlib/setenv.c
+++ b/stdlib/setenv.c
@@ -19,12 +19,14 @@
 # include <config.h>
 #endif
 
-/* Pacify GCC; see the commentary about VALLEN below.  This is needed
-   at least through GCC 4.9.2.  Pacify GCC for the entire file, as
-   there seems to be no way to pacify GCC selectively, only for the
-   place where it's needed.  Do not use DIAG_IGNORE_NEEDS_COMMENT
-   here, as it's not defined yet.  */
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+/* Pacify GCC 4.7 and later; see the commentary about VALLEN below.
+   This is needed at least through GCC 5.1.0.  Pacify GCC for the
+   entire file, as there seems to be no way to pacify GCC selectively,
+   only for the place where it's needed.  Do not use macros like
+   DIAG_IGNORE_NEEDS_COMMENT here, as they're not defined yet.  */
+#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
+# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
 
 #include <errno.h>
 #if !_LIBC
-- 
2.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]