about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-11-25 14:12:48 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2014-11-25 14:20:53 -0800
commitb1eda10e17bf2056ca79a534d92fe0b0b06bd410 (patch)
tree0ae624bdeb264f2a7a11e2fd2266f73acbc56af9 /posix
parentbde2667a22c355467a4f07246c6d07a9dcc89366 (diff)
downloadglibc-b1eda10e17bf2056ca79a534d92fe0b0b06bd410.tar.gz
glibc-b1eda10e17bf2056ca79a534d92fe0b0b06bd410.tar.xz
glibc-b1eda10e17bf2056ca79a534d92fe0b0b06bd410.zip
fnmatch: work around GCC compiler warning bug with uninit var
* posix/fnmatch_loop.c (FCT): Use a scalar not a one-item array.
This works around a bug with x86-64 GCC 4.9.2 and earlier
where 'gcc -O2 -Wmaybe-uninitialized' incorrectly complains
"../locale/weightwc.h:93:7: warning: '*((void *)&str+4)' may be
used uninitialized in this function [-Wmaybe-uninitialized]".
Diffstat (limited to 'posix')
-rw-r--r--posix/fnmatch_loop.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
index db6d9d7c56..1e27913cf1 100644
--- a/posix/fnmatch_loop.c
+++ b/posix/fnmatch_loop.c
@@ -343,7 +343,12 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
 #ifdef _LIBC
 		else if (c == L('[') && *p == L('='))
 		  {
-		    UCHAR str[1];
+		    /* It's important that STR be a scalar variable rather
+		       than a one-element array, because GCC (at least 4.9.2
+		       -O2 on x86-64) can be confused by the array and
+		       diagnose a "used initialized" in a dead branch in the
+		       findidx function.  */
+		    UCHAR str;
 		    uint32_t nrules =
 		      _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
 		    const CHAR *startp = p;
@@ -355,7 +360,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
 			c = L('[');
 			goto normal_bracket;
 		      }
-		    str[0] = c;
+		    str = c;
 
 		    c = *++p;
 		    if (c != L('=') || p[1] != L(']'))
@@ -368,7 +373,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
 
 		    if (nrules == 0)
 		      {
-			if ((UCHAR) *n == str[0])
+			if ((UCHAR) *n == str)
 			  goto matched;
 		      }
 		    else
@@ -383,7 +388,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
 # endif
 			const int32_t *indirect;
 			int32_t idx;
-			const UCHAR *cp = (const UCHAR *) str;
+			const UCHAR *cp = (const UCHAR *) &str;
 
 # if WIDE_CHAR_VERSION
 			table = (const int32_t *)