Skip to content

Conversation

patrykstefanski
Copy link

Check assignments to count-attributed objects that are implicitly immutable. For example, assigning to a dependent count that is used in an inout pointer is not allowed, since the update won't be visible on the call-site:

  void foo(int *__counted_by(count) *out_p, int count) {
    *out_p = ...;
    count = ...; // immutable
  }

rdar://161608157

@patrykstefanski patrykstefanski self-assigned this Oct 13, 2025
@patrykstefanski patrykstefanski added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Oct 13, 2025
Copy link

@ziqingluo-90 ziqingluo-90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall! I left some minor comments, address at your will.

…nt-attributed objects

Check assignments to count-attributed objects that are implicitly
immutable.  For example, assigning to a dependent count that is used in
an inout pointer is not allowed, since the update won't be visible on
the call-site:

```
  void foo(int *__counted_by(count) *out_p, int count) {
    *out_p = ...;
    count = ...; // immutable
  }
```

rdar://161608157
@patrykstefanski patrykstefanski force-pushed the eng/pstefanski/PR-161608157 branch from 1c8ac19 to 91cf7f5 Compare October 17, 2025 19:21
@patrykstefanski
Copy link
Author

@swift-ci test llvm

@patrykstefanski patrykstefanski merged commit 7f73488 into swiftlang:next Oct 17, 2025
0 of 2 checks passed
@patrykstefanski patrykstefanski deleted the eng/pstefanski/PR-161608157 branch October 17, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants