-
Notifications
You must be signed in to change notification settings - Fork 205
gccrs: avoid ICE on generic const expressions in path resolution #4341
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
base: master
Are you sure you want to change the base?
gccrs: avoid ICE on generic const expressions in path resolution #4341
Conversation
896d6ad to
1b1c341
Compare
CohenArthur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks great, only a few issues but nothing bad. Once this is fixed I'm happy to merge your PR. Thanks for your contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to update the Changelog file manually - it gets updated automatically by a script every day in the upstream GCC repo :) please restore the file here or it may cause issues
e9afc67 to
3d52076
Compare
|
All checks are now passing and the PR is ready for merge. @CohenArthur Thanks a lot for the review and helpful feedback — it clarified the expected coding style and workflow. I’ll keep future PRs focused with a clean commit history. Please let me know if there’s anything else I should adjust. |
546caf5 to
56a7611
Compare
|
@P-E-P please review . thankyou |
philberty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... i am not 100% sure this is the correct place to handle this because at this case is where it should be lazy evaluated and monomophized so i think this will cause false positives for other cases.
This should be handled in the typecheck pass when we resolve generic arguments instead where case cannot do N + 1 because N is not defined at this case.
|
okay , i will look into that . thanks for pointing this out . |
ba38fc7 to
8a9448e
Compare
Generic const expressions such as { N + 1 } are symbolic and cannot be
evaluated immediately during type checking path resolution. Previously,
these expressions were allowed to propagate, leading to assertion failures
and internal compiler errors (ICE) in the backend when it attempted to
resolve them as concrete values.
This patch adds validation in the typechecker to detect non-literal
const generic arguments during path resolution. It rejects symbolic
expressions gracefully by emitting a diagnostic, preventing the compiler
from crashing.
Fixes Rust-GCC#4302
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path):
Reject non-literal generic const arguments to prevent ICE.
(TypeCheckExpr::resolve_segments): Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4302.rs: New test.
Signed-off-by: Jayant Chauhan <[email protected]>
8a9448e to
a403b82
Compare
Fixes #4302
ResolvePathRef::resolve_with_node_id assumed CONST types were always concrete values and asserted otherwise. Generic const expressions such as
{ N + 1 }are symbolic and cannot be evaluated prior to monomorphization, leading to an internal compiler error.Reject non-value const kinds gracefully and emit a diagnostic instead of aborting.
gcc/testsuite:
* rust/compile/const-generic-ice-4302.rs: New test.
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
make check-rustpasses locallyclang-formatgcc/testsuite/rust/Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.