Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccrs: fix ICE in borrows to invalid expressions #3356

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

philberty
Copy link
Member

We need to check if the borrowed value is valid before creating the reference type. Otherwise this will lead to an ICE.

Fixes #3140

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): likewise and remove debug error

gcc/testsuite/ChangeLog:

* rust/compile/issue-3046.rs: remove old error message
* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3140.rs: New test.

We need to check if the borrowed value is valid before creating the
reference type. Otherwise this will lead to an ICE.

Fixes #3140

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): check for error
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): likewise and remove debug error

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3046.rs: remove old error message
	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3140.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

LGTM!

@philberty philberty added this pull request to the merge queue Jan 7, 2025
Merged via the queue into master with commit 5bccf14 Jan 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Using wrong enum variant results in ice
2 participants