Skip to content

__builtin_dynamic_object_size does not report size of function argument VLAs #151240

@kees

Description

@kees

For function argument VLAs, GCC correctly reports the expected size. Clang seems unaware:

#include <stdio.h>

void __attribute__((noinline))
foo(int n, short array[n])
{
        printf("%zu\n", __builtin_dynamic_object_size(array, 1));
}

int main(void)
{
        short array[10];

        foo(10, array);
        return 0;
}
$ gcc -Wall -O2 -o fvla-gcc fvla.c && ./fvla-gcc
20
$ clang -Wall -O2 -o fvla-clang fvla.c && ./fvla-clang
18446744073709551615

@bwendling

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions