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 24246 - This eliminates the ICE, stopping the bleed, but do… #15818

Closed
wants to merge 1 commit into from

Conversation

maxhaton
Copy link
Member

…es not fix the underlying issue in that the type checking is faulty.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @maxhaton!

Bugzilla references

Auto-close Bugzilla Severity Description
24246 critical ICE: CTFE internal error: literal 'TypeExp' in src/dmd/ctfeexpr.d(439)

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#15818"

error(e.loc, "CTFE internal error: literal `%s`", e.toChars());
assert(0);
error(e.loc, "CTFE internal error: literal `%s` could not be copied.", e.toChars());
return UnionExp(CTFEExp.cantexp);
Copy link
Member

Choose a reason for hiding this comment

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

Use fatal() instead.

.error(ti.loc, "%s `%s` internal compiler error: C++ `%s` template value parameter is not supported", ti.kind, ti.toPrettyChars, tv.valType.toChars());

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if it should be completely fatal while it triggers so easily

Copy link
Member

Choose a reason for hiding this comment

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

It took years to find it. :-)

Copy link
Member

Choose a reason for hiding this comment

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

The one I linked is trivial to hit as well. Mix any D type (arrays) with extern C++.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it realistic to recover from that in an IsExp (say)?

Copy link
Member

Choose a reason for hiding this comment

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

It's an internal error, you're not meant to be able to recover.

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, this ICE is a result of a failure of semantic to analyse condexps properly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its effectively a type check done way too late is my thinking. It should be fatal when the code actuall works but its not CondExps as much as a vast surface area of the type checking being totally bogus.

…es not fix the underlying issue in that the type checking is faulty.

auto f24246(int i)
{
return true ? int : i;
Copy link

@ghost ghost Nov 16, 2023

Choose a reason for hiding this comment

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

When does a primary exp such as int is accepted since ?

It is like https://issues.dlang.org/show_bug.cgi?id=24229.

Copy link

@ghost ghost Nov 16, 2023

Choose a reason for hiding this comment

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

INitially that comes from an alias presumably ? IdentExp -> AliasDecl -> TypeExp ? Even if apparently it is also accepted as-is.

@RazvanN7
Copy link
Contributor

I don't see the point in merging this. The assert(0) technically should never be reached and is put there as a precautionary measure. Deleting it and turning it into a normal error is only going to make it harder in the future to track where the issue is coming from. I suggest you either fix the issue or leave it as is - using fatal or error adds no benefit in my opinion.

@maxhaton
Copy link
Member Author

I don't see the point in merging this. The assert(0) technically should never be reached and is put there as a precautionary measure. Deleting it and turning it into a normal error is only going to make it harder in the future to track where the issue is coming from. I suggest you either fix the issue or leave it as is - using fatal or error adds no benefit in my opinion.

Currently the assert(0) just makes the compiler blow up without even an ICE message. It's a bit lazy.

It should not be reachable at all, by construction, it's the type checker that's broken. Fixing that will not be particularly trivial, this effectively steps in as a bit of post-hoc type checking. The fact that it says internal error has been maintained but is honestly kind of meaningless.

@RazvanN7
Copy link
Contributor

RazvanN7 commented Jan 10, 2024

@maxhaton That's preferable because turning it into an error will make it liable to error gagging. Consider the case where the problematic code is triggered from a typeof expression. What will happen: you will mask the error and continue compilation (and if fatal is used, it will seem that compilation has exited gracefully but no binary was created).

That's why I think that we should leave the assert as is until we fix the issue. Turning it into an error really doesn't buy as anything, whereas the assertion will make users submit bug reports with cases that we need to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants