[clang] [Bounds-Safety] Add sized_by, counted_by_or_null & sized_by_or_null (PR #93231)
Henrik G. Olsson via cfe-commits
cfe-commits at lists.llvm.org
Fri May 24 14:01:11 PDT 2024
================
@@ -8697,9 +8708,10 @@ static bool CheckCountedByAttrOnField(
InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER;
}
- if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) {
+ if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID &&
+ !CountInBytes) {
----------------
hnrklssn wrote:
I think that is a reasonable restriction to add in `-fbounds-safety`, but for simply saying "this is the size", is it really an issue? It's also feasible to allow the attribute, but not allow indexing into an unsized type. That would make it possible to cast to `char * sized_by(sz)` and retain the size bounds before indexing into it.
https://github.com/llvm/llvm-project/pull/93231
More information about the cfe-commits
mailing list