Repository navigation
Avoid indexing SubstitutionMap with temporary TypeParamType names. - #2474
Merged
Merged
Conversation
`Type::GetTypeParam()` and `Type::AsTypeParam()` return temporary objects, and the compiler assumes their `ABSL_ATTRIBUTE_LIFETIME_BOUND` `name()` view expires at the end of the full-expression. Passing that rvalue view directly to `SubstitutionMap::operator[]` triggers `-Wdangling-capture` when hash-table lifetime-capture annotations check rvalue view keys. The diagnostic is a false positive: `TypeParamType` does not own its name, so the view outlives the temporary. Bind the extracted `TypeParamType` and its `name()` to local variables in `IsAssignableInternal` and `IsAssignableWithConstraints` before indexing the substitution map. Behavior is unchanged. PiperOrigin-RevId: 1026909127
copybara-service
Bot
force-pushed
the
test_1026854027
branch
from
November 21, 2026 03:02
8e6c9d8 to
54ec23e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid indexing SubstitutionMap with temporary TypeParamType names.
Type::GetTypeParam()andType::AsTypeParam()return temporary objects, andthe compiler assumes their
ABSL_ATTRIBUTE_LIFETIME_BOUNDname()viewexpires at the end of the full-expression. Passing that rvalue view directly to
SubstitutionMap::operator[]triggers-Wdangling-capturewhen hash-tablelifetime-capture annotations check rvalue view keys. The diagnostic is a false
positive:
TypeParamTypedoes not own its name, so the view outlives thetemporary.
Bind the extracted
TypeParamTypeand itsname()to local variables inIsAssignableInternalandIsAssignableWithConstraintsbefore indexing thesubstitution map. Behavior is unchanged.