[LLVMbugs] [Bug 21614] New: strcmp() (that does "x"[3]) generates an unused-value warning on 32bit
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Nov 20 04:56:56 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=21614
Bug ID: 21614
Summary: strcmp() (that does "x"[3]) generates an unused-value
warning on 32bit
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: lkundrak at v3.sk
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
On Fedora 21 with glibc 2.20 the following happens:
[lkundrak at belphegor libnm-core]$ cat tc1.c
#include <string.h>
void
f ()
{
strcmp ("something", "0");
}
[lkundrak at belphegor libnm-core]$ clang -O2 -Wno-unused-value -c tc1.c
tc1.c:6:1986: warning: array index 2 is past the end of the array (which
contains 2 elements) [-Warray-bounds]
__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
("something") && __builtin_constant_p ("0") && (__s1_len = strlen
("something"), __s2_len = strlen ("0"), (!((size_t)(const void *)(("something")
+ 1) - (size_t)(const void *)("something") == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)(("0") + 1) - (size_t)(const void *)("0") == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ("something", "0") : (__builtin_constant_p
("something") && ((size_t)(const void *)(("something") + 1) - (size_t)(const
void *)("something") == 1) && (__s1_len = strlen ("something"), __s1_len < 4) ?
(__builtin_constant_p ("0") && ((size_t)(const void *)(("0") + 1) -
(size_t)(const void *)("0") == 1) ? __builtin_strcmp ("something", "0") :
(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ("0"); int __result = (((const unsigned char *) (const char *)
("something"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result =
(((const unsigned char *) (const char *) ("something"))[1] - __s2[1]); if
(__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const
char *) ("something"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0)
__result = (((const unsigned char *) (const char *) ("something"))[3] -
__s2[3]); } } __result; }))) : (__builtin_constant_p ("0") && ((size_t)(const
void *)(("0") + 1) - (size_t)(const void *)("0") == 1) && (__s2_len = strlen
("0"), __s2_len < 4) ? (__builtin_constant_p ("something") && ((size_t)(const
void *)(("something") + 1) - (size_t)(const void *)("something") == 1) ?
__builtin_strcmp ("something", "0") : (- (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) ("something"); int __result =
(((const unsigned char *) (const char *) ("0"))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char *) (const char *)
("0"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) ("0"))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char *) ("0"))[3] -
__s2[3]); } } __result; })))) : __builtin_strcmp ("something", "0")))); });
^ ~
tc1.c:6:2095: warning: array index 3 is past the end of the array (which
contains 2 elements) [-Warray-bounds]
__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
("something") && __builtin_constant_p ("0") && (__s1_len = strlen
("something"), __s2_len = strlen ("0"), (!((size_t)(const void *)(("something")
+ 1) - (size_t)(const void *)("something") == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)(("0") + 1) - (size_t)(const void *)("0") == 1) ||
__s2_len >= 4)) ? __builtin_strcmp ("something", "0") : (__builtin_constant_p
("something") && ((size_t)(const void *)(("something") + 1) - (size_t)(const
void *)("something") == 1) && (__s1_len = strlen ("something"), __s1_len < 4) ?
(__builtin_constant_p ("0") && ((size_t)(const void *)(("0") + 1) -
(size_t)(const void *)("0") == 1) ? __builtin_strcmp ("something", "0") :
(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const
char *) ("0"); int __result = (((const unsigned char *) (const char *)
("something"))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result =
(((const unsigned char *) (const char *) ("something"))[1] - __s2[1]); if
(__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const
char *) ("something"))[2] - __s2[2]); if (__s1_len > 2 && __result == 0)
__result = (((const unsigned char *) (const char *) ("something"))[3] -
__s2[3]); } } __result; }))) : (__builtin_constant_p ("0") && ((size_t)(const
void *)(("0") + 1) - (size_t)(const void *)("0") == 1) && (__s2_len = strlen
("0"), __s2_len < 4) ? (__builtin_constant_p ("something") && ((size_t)(const
void *)(("something") + 1) - (size_t)(const void *)("something") == 1) ?
__builtin_strcmp ("something", "0") : (- (__extension__ ({ const unsigned char
*__s2 = (const unsigned char *) (const char *) ("something"); int __result =
(((const unsigned char *) (const char *) ("0"))[0] - __s2[0]); if (__s2_len > 0
&& __result == 0) { __result = (((const unsigned char *) (const char *)
("0"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) ("0"))[2] - __s2[2]); if (__s2_len > 2 &&
__result == 0) __result = (((const unsigned char *) (const char *) ("0"))[3] -
__s2[3]); } } __result; })))) : __builtin_strcmp ("something", "0")))); });
^ ~
2 warnings generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141120/5e5c1b69/attachment.html>
More information about the llvm-bugs
mailing list