zygoloid wrote:
> > If that mode doesn't already permit using unknown pointers and references
> > in all language modes, then we should change it so that it does.
> > `__builtin_object_size` is best-effort, but we should produce a constant
> > value for it that's not the `-1` or `0` fallback value whenever we're able
> > to do so.
>
> But there isn't much we can do with unknown pointers or references, is there?
>
> We can't have `foo` return 4 unless we know for sure that `s` isn't embedded
> in a larger object. In the following case, wouldn't `foo` be expected to
> return 12?
>
> ```
> int bar() {
> S a[2];
> return foo(a[0]);
> }
> ```
It depends on the mode parameter in `__builtin_object_size`. For mode 1 and 3,
we can use the access path and return 4 if `-fstrict-flex-arrays` is strict
enough. For mode 0 or 2, or with lax flexible array rules, I agree that we
can't conclude anything and would need to return `0` / `-1`.
https://github.com/llvm/llvm-project/pull/95474
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits