olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1505492-uninit-3.patch

25845f
commit b1eda10e17bf2056ca79a534d92fe0b0b06bd410
25845f
Author: Paul Eggert <eggert@cs.ucla.edu>
25845f
Date:   Tue Nov 25 14:12:48 2014 -0800
25845f
25845f
    fnmatch: work around GCC compiler warning bug with uninit var
25845f
    
25845f
    * posix/fnmatch_loop.c (FCT): Use a scalar not a one-item array.
25845f
    This works around a bug with x86-64 GCC 4.9.2 and earlier
25845f
    where 'gcc -O2 -Wmaybe-uninitialized' incorrectly complains
25845f
    "../locale/weightwc.h:93:7: warning: '*((void *)&str+4)' may be
25845f
    used uninitialized in this function [-Wmaybe-uninitialized]".
25845f
25845f
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
25845f
index e289f451cc23c1ee..2bd788f3942c6e7d 100644
25845f
--- a/posix/fnmatch_loop.c
25845f
+++ b/posix/fnmatch_loop.c
25845f
@@ -342,7 +342,12 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
25845f
 #ifdef _LIBC
25845f
 		else if (c == L('[') && *p == L('='))
25845f
 		  {
25845f
-		    UCHAR str[1];
25845f
+		    /* It's important that STR be a scalar variable rather
25845f
+		       than a one-element array, because GCC (at least 4.9.2
25845f
+		       -O2 on x86-64) can be confused by the array and
25845f
+		       diagnose a "used initialized" in a dead branch in the
25845f
+		       findidx function.  */
25845f
+		    UCHAR str;
25845f
 		    uint32_t nrules =
25845f
 		      _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
25845f
 		    const CHAR *startp = p;
25845f
@@ -354,7 +359,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
25845f
 			c = L('[');
25845f
 			goto normal_bracket;
25845f
 		      }
25845f
-		    str[0] = c;
25845f
+		    str = c;
25845f
 
25845f
 		    c = *++p;
25845f
 		    if (c != L('=') || p[1] != L(']'))
25845f
@@ -367,7 +372,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
25845f
 
25845f
 		    if (nrules == 0)
25845f
 		      {
25845f
-			if ((UCHAR) *n == str[0])
25845f
+			if ((UCHAR) *n == str)
25845f
 			  goto matched;
25845f
 		      }
25845f
 		    else
25845f
@@ -382,7 +387,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
25845f
 # endif
25845f
 			const int32_t *indirect;
25845f
 			int32_t idx;
25845f
-			const UCHAR *cp = (const UCHAR *) str;
25845f
+			const UCHAR *cp = (const UCHAR *) &str;
25845f
 
25845f
 			/* This #include defines a local function!  */
25845f
 # if WIDE_CHAR_VERSION