[PATCH] D148381: [Clang] Implement the 'counted_by' attribute

Yeoul Na via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 15 17:06:35 PDT 2023


rapidsna added a comment.

  struct V {
    int Sizes[2];
    int FAM[] __counted_by(Sizes[0]); // Thoughts?
  };

`-fbounds-safety` doesn't allow this. In our internal adoption experience, we haven't encountered such use cases yet. So, I think it's best to make the model restrictive to avoid surprises. If we were to support it, I think it should at least be limited to cases where the array subscript expression is known to be in bounds at compile time, to avoid an OOB access when the counted_by argument is evaluated.


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