Skip to content

Avoid indexing SubstitutionMap with temporary TypeParamType names. - #2474

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1026854027
Nov 21, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1026854027

Conversation

@copybara-service

Copy link
Copy Markdown

Avoid indexing SubstitutionMap with temporary TypeParamType names.

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.

`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
copybara-service Bot merged commit 54ec23e into master Nov 21, 2026
3 of 4 checks passed
@copybara-service
copybara-service Bot deleted the test_1026854027 branch November 21, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant