[llvm-dev] Question about __builtin_object_size
Strahinja Petrovic via llvm-dev
llvm-dev at lists.llvm.org
Tue Feb 9 06:37:25 PST 2016
Hi,
I have question about __builtin_object_size behaviour. LLVM for
__builtin_object_size function doesn't calculate correct value when
pointer is used only in __builtin_object_size function call, and never
after that. For this case LLVM as result generates 0 or -1 depends of
second argument of __builtin_object_size function. Is this correct
behaviour or it should work as gcc (gcc calculates correct value for
this case) ?
Example for this issue:
include <assert.h>
int main() {
struct V { char buf1[10];
int b;
char buf2[10];
} var;
char *p = &var.buf1[1], *q = &var.b;
assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
return 0;
}
Thanks,
Strahinja
More information about the llvm-dev
mailing list