<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Clang warnings for optimizations in GCC string.h"
href="https://llvm.org/bugs/show_bug.cgi?id=28583">28583</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang warnings for optimizations in GCC string.h
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jibz-llvmbugs@stdip.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16751" name="attach_16751" title="Output of clang -E -frewrite-includes -O2 -c foo.c">attachment 16751</a> <a href="attachment.cgi?id=16751&action=edit" title="Output of clang -E -frewrite-includes -O2 -c foo.c">[details]</a></span>
Output of clang -E -frewrite-includes -O2 -c foo.c
Compiling foo.c:
#include <string.h>
int main() { (void) strspn("foo", "f"); }
on Linux with `clang -O2 -c foo.c' results in:
[jibsen@localhost build]$ clang -O2 -c foo.c
foo.c:2:498: warning: array index 2 is past the end of the array (which
contains 2 elements) [-Warray-bounds]
int main() { (void) __extension__ ({ char __a0, __a1, __a2;
(__builtin_constant_p ("f") && ((size_t)(const void *)(("f") + 1) -
(size_t)(const void *)("f") == 1) ? ((__builtin_constant_p ("foo") &&
((size_t)(const void *)(("foo") + 1) - (size_t)(const void *)("foo") == 1)) ?
__builtin_strspn ("foo", "f") : ((__a0 = ((const char *) ("f"))[0], __a0 ==
'\0') ? ((void) ("foo"), (size_t) 0) : ((__a1 = ((const char *) ("f"))[1], __a1
== '\0') ? __strspn_c1 ("foo", __a0) : ((__a2 = ((const char *) ("f"))[2], __a2
== '\0') ? __strspn_c2 ("foo", __a0, __a1) : (((const char *) ("f"))[3] == '\0'
? __strspn_c3 ("foo", __a0, __a1, __a2) : __builtin_strspn ("foo", "f")))))) :
__builtin_strspn ("foo", "f")); }); }
^ ~
foo.c:2:576: warning: array index 3 is past the end of the array (which
contains 2 elements) [-Warray-bounds]
int main() { (void) __extension__ ({ char __a0, __a1, __a2;
(__builtin_constant_p ("f") && ((size_t)(const void *)(("f") + 1) -
(size_t)(const void *)("f") == 1) ? ((__builtin_constant_p ("foo") &&
((size_t)(const void *)(("foo") + 1) - (size_t)(const void *)("foo") == 1)) ?
__builtin_strspn ("foo", "f") : ((__a0 = ((const char *) ("f"))[0], __a0 ==
'\0') ? ((void) ("foo"), (size_t) 0) : ((__a1 = ((const char *) ("f"))[1], __a1
== '\0') ? __strspn_c1 ("foo", __a0) : ((__a2 = ((const char *) ("f"))[2], __a2
== '\0') ? __strspn_c2 ("foo", __a0, __a1) : (((const char *) ("f"))[3] == '\0'
? __strspn_c3 ("foo", __a0, __a1, __a2) : __builtin_strspn ("foo", "f")))))) :
__builtin_strspn ("foo", "f")); }); }
^ ~
2 warnings generated.
I haven'd dug through the macros, but I assume Clang is not supposed to
generate warnings for standard functions, at least without any warning flags.
Attached is output of clang -E -frewrite-includes.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>