[PATCH] D148381: [WIP][Clang] Add counted_by attribute
Yeoul Na via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 23 18:07:13 PDT 2023
rapidsna added a comment.
> Future additions will include supporting, FAMs and counts in
sub-structures.
For sub-structures, are you referring to cases like this?
struct outer {
struct {
int count;
} sub;
int flex[__attribute__((counted_by(sub.count)))];
};
For `-fbounds-safety` we would limit it to anonymous sub-structs only because otherwise the code can create a pointer to sub-struct and its count can easily be updated to an invalid count. Were you considering the same restrictions for this?
void foo(struct outer *p1, struct sub *p2) {
p1 = (int*)malloc(sizeof(int) *10);
p1->count = 10;
p2->count = INT_MAX;
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148381/new/
https://reviews.llvm.org/D148381
More information about the cfe-commits
mailing list