Cydox wrote:

> ```
> struct S {
>     int foo;
>     char fam[N];
> };
> ```
> 
> Well, for N = 4 we have `sizeof(struct S) == 8` and for N = 5 we have 
> `sizeof(struct S) == 12` (due to alignment padding), therefore N = 4. That 
> makes `s->fam[4]` out-of-bounds. Am I wrong?

Using this example, every object of sizes 8 to 11 bytes, inclusive behaves like 
the struct defined with N = 4. Therefore `__bdos(ptr, 0)`, where `ptr` is a 
pointer to a `struct S` with a `__counted_by` attribute indicating N = 4, 
should return 11. `__bdos(ptr, 2)` should return 8.

https://github.com/llvm/llvm-project/pull/112636
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to