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

Fix Issue 21794 - ICE: Assertion hit in dinterpret.d #13172

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

BorisCarvajal
Copy link
Member

When casting null to integer/real instead of painting the type on the NullExp, we emplace an IntegerExp/RealExp with value zero like when casting from NullExp to bool.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @BorisCarvajal!

Bugzilla references

Auto-close Bugzilla Severity Description
21794 critical Internal compiler assertion

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#13172"

@UplinkCoder
Copy link
Member

UplinkCoder commented Oct 15, 2021

The commit message is not particularly good.
I can see what the code is doing.
Rather than the what happens explain why it should do it.
And what the issue was in the first place.
I assume from reading solution that the issue there was a node expected to be of type 0 or 0.0 but you got null instead.

Copy link
Member

@UplinkCoder UplinkCoder left a comment

Choose a reason for hiding this comment

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

The code itself is fine.
Please change the commit message though :)

if (tobt.isintegral())
emplaceExp!(IntegerExp)(pue, e.loc, 0, e.to);
else if (tobt.isreal())
emplaceExp!(RealExp)(pue, e.loc, 0, e.to);
Copy link
Member

Choose a reason for hiding this comment

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

it says that a longdouble_soft is expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@BorisCarvajal
Copy link
Member Author

Commit message improved a little, it's really brief like every bug fix on the repo.

@dlang-bot dlang-bot merged commit 712632c into dlang:stable Oct 16, 2021
kraj pushed a commit to kraj/gcc that referenced this pull request Jul 1, 2023
Backports ICE fix from upstream.  When casting null to integer or real,
instead of painting the type on the NullExp, we emplace an
IntegerExp/RealExp with the value zero.  Same as when casting from
NullExp to bool.

Reviewed-on: dlang/dmd#13172

	PR d/110511

gcc/d/ChangeLog:

	* dmd/dinterpret.c (Interpreter::visit (CastExp *)): Handle casting
	null to int or float.

gcc/testsuite/ChangeLog:

	* gdc.test/compilable/test21794.d: New test.

(cherry picked from commit 066385c)
kraj pushed a commit to kraj/gcc that referenced this pull request Jul 1, 2023
Backports ICE fix from upstream.  When casting null to integer or real,
instead of painting the type on the NullExp, we emplace an
IntegerExp/RealExp with the value zero.  Same as when casting from
NullExp to bool.

Reviewed-on: dlang/dmd#13172

	PR d/110511

gcc/d/ChangeLog:

	* dmd/dinterpret.c (Interpreter::visit (CastExp *)): Handle casting
	null to int or float.

gcc/testsuite/ChangeLog:

	* gdc.test/compilable/test21794.d: New test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants