[llvm-dev] Question about __builtin_object_size

Xinliang David Li via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 9 11:06:06 PST 2016


What version of clang/LLVM are you using? George (cc'ed ) has improved
__builtin_object_size support in Clang recently.

David

On Tue, Feb 9, 2016 at 6:37 AM, Strahinja Petrovic via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> 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
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160209/a57c04a1/attachment.html>


More information about the llvm-dev mailing list