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

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