[clang] [BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C (PR #90786)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Fri May 17 15:56:43 PDT 2024
delcypher wrote:
@bwendling This is unfortunate
```
drivers/gpu/drm/radeon/pptable.h:442:5: error: 'counted_by' cannot be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
Based on our previous discussion (https://github.com/llvm/llvm-project/pull/90786#issuecomment-2108855275) I hope we can agree using the attribute this way is problematic. I don't see how `states` could be have its bounds correctly computed when the compiler doesn't know how big `struct _ATOM_PPLIB_STATE_V2` actually is.
To unbreak this particular use quickly I'll downgrade the struct with FAM case to a warning and from there we'll need to decide how to proceed.
https://github.com/llvm/llvm-project/pull/90786
More information about the cfe-commits
mailing list