<html>
<head>
<base href="http://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 handles __builtin_object_size in wrong way"
href="http://llvm.org/bugs/show_bug.cgi?id=15212">15212</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang handles __builtin_object_size in wrong way
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.2
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ili.filippov@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>__builtin_object_size (void * ptr, int type) returns a constant number of bytes
from ptr to the end of the object ptr pointer points to.
But if type == 1 it understands object as the nearest surrounding of ptr and if
type == 0 it understands object as the whole object, contains the object
ptr points to.
If we write simple example:
#include <stdio.h>
struct a
{
int t[10];
};
int main()
{
a t[10];
printf("%d\n",__builtin_object_size(&t[0].t[0],0));
return 0;
}
Clang will answer 400 and it is right, because it is 4*10*10
But if we changed
printf("%d\n",__builtin_object_size(&t[0].t[0],0));
to
printf("%d\n",__builtin_object_size(&t[0].t[0],1));
Clang will also answer 400 and it is wrong, because the size of t.t is only 40
(10*4).
--
Software Engineer
Intel Compiler Team
Intel Corp.</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>