ahatanak wrote:
Shouldn't it return false even in contexts that don't require constant
evaluation?
The following function (adapted from
`test/AST/ByteCode/builtin-object-size-codegen.cpp`) returns 16 because
`determineEndOffset` uses a conservative lower bound. gcc returns 32.
```
#include <cstdlib>
int foo() {
struct A { char buf[16]; };
struct B : A {};
struct C { int i; B bs[1]; } *c = (C*)malloc(sizeof(C) + sizeof(B));
int gi;
gi = __builtin_object_size(&c->bs[0], 3);
return gi;
}
```
This is exactly the case where the underlying object could become known later.
https://github.com/llvm/llvm-project/pull/157778
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits