<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 --- - objectsize should not be lowered to unknown before inlining"
href="https://llvm.org/bugs/show_bug.cgi?id=23280">23280</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>objectsize should not be lowered to unknown before inlining
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>danielmicay@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This will output 2 with `gcc -O2` but (size_t)-1 with Clang:
#include <stdio.h>
#include <stdlib.h>
static inline __attribute__((always_inline)) size_t object_size(char *p) {
return __builtin_object_size(p, 0);
}
int main(int argc, char **argv) {
char buf[2];
printf("%zu\n", object_size(buf));
return 0;
}
This means that _FORTIFY_SOURCE buffer size checks do not currently work with
Clang because it lowers the __builtin_object_size calls to (size_t)-1 before
the wrappers are inlined into the call sites. This will also break other
compelling use cases for this feature. It makes a lot of sense to lower it to a
*known* value pre-inlining to get more work done in the early function passes,
but replacing it with -1 before then isn't good.</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>