Skip to content

Conversation

@patrykstefanski
Copy link

BoundsSafety can reuse the same CompoundLiteralExpr in a bounds-check condition. This commit changes const-eval for CompoundLiteralExpr to reset the state and evaluate it again when the temporary for that CompoundLiteralExpr already exists.

In addition, we skip const-eval in Sema when building a bounds-check condition. That const-eval is used only for diagnostics and we don't want to diagnose AST that we are generating.

This is merely a workaround. The proper solution is to not emit the AST for bounds-check condition and defer it to CodeGen.

rdar://157033241

(cherry picked from commit 80d3756)

BoundsSafety can reuse the same CompoundLiteralExpr in a bounds-check
condition. This commit changes const-eval for CompoundLiteralExpr to
reset the state and evaluate it again when the temporary for that
CompoundLiteralExpr already exists.

In addition, we skip const-eval in Sema when building a bounds-check
condition. That const-eval is used only for diagnostics and we don't
want to diagnose AST that we are generating.

This is merely a workaround. The proper solution is to not emit the AST
for bounds-check condition and defer it to CodeGen.

rdar://157033241
(cherry picked from commit 80d3756)
@patrykstefanski patrykstefanski self-assigned this Oct 20, 2025
@patrykstefanski patrykstefanski added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Oct 20, 2025
@patrykstefanski
Copy link
Author

@swift-ci test

@patrykstefanski
Copy link
Author

@swift-ci test llvm

@patrykstefanski
Copy link
Author

@swift-ci test Windows platform

@patrykstefanski
Copy link
Author

@swift-ci test llvm

@patrykstefanski patrykstefanski merged commit 0089ca9 into swiftlang:stable/21.x Oct 22, 2025
3 of 5 checks passed
@patrykstefanski patrykstefanski deleted the eng/pstefanski/PR-157033241-21.x branch October 22, 2025 17:09
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