[LLVMbugs] [Bug 15212] New: Clang handles __builtin_object_size in wrong way
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Feb 8 02:54:39 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=15212
Bug ID: 15212
Summary: Clang handles __builtin_object_size in wrong way
Product: clang
Version: 3.2
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: ili.filippov at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
__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.
--
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/20130208/fb74e0c5/attachment.html>
More information about the llvm-bugs
mailing list