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 21492 - betterC: TypeInfo is generated for code guarded by … #14830

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

WalterBright
Copy link
Member

…if(__ctfe)

Code protected by if (__ctfe) need not have any code generated for it, as illustrated by the bug report. Generating code for it anyway will trigger an error that certain things are not allowed in -betterC code, but are allowed in ctfe code.

Normally, the backend will do just fine eliminating such dead code. But the error detection occurs before the backend. To do it thoroughly in the front end requires data flow analysis. But that's awful expensive for just this problem. So this PR implements a rather primitive method which will handle the usual cases. The cases it doesn't handle (and such can be easily contrived) will still trigger the error. But such are easily rewritten into the form that is accepted, so nothing is worse off.

More cases can be worked in if the future if it becomes necessary.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
21492 normal betterC: TypeInfo is generated for code guarded by if(__ctfe)

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 "master + dmd#14830"

@WalterBright
Copy link
Member Author

This is failing to compile d_test_run.d with an assert failure:

core.exception.AssertError@src/dmd/backend/elfobj.d(3108): Assertion failure

It would be better if the test runner is compiled with the bootstrap compiler, so the compiler tests can be run.

@WalterBright WalterBright force-pushed the fix21492 branch 2 times, most recently from 84977e7 to 4d7a984 Compare January 16, 2023 23:23
case 1:
if (__ctfe)
{
{ int[] foo = [1]; }
Copy link
Member

Choose a reason for hiding this comment

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

Use correct indentation.

@WalterBright
Copy link
Member Author

The Cybershadow failure appears to be a heisenbug. This PR is ready to go.

@RazvanN7 RazvanN7 merged commit a15cf38 into dlang:master Jan 17, 2023
@WalterBright WalterBright deleted the fix21492 branch January 17, 2023 18:25
@ibuclaw
Copy link
Member

ibuclaw commented Feb 12, 2023

Do we really need more special cases?

@ibuclaw
Copy link
Member

ibuclaw commented Feb 15, 2023

This PR caused a regression https://issues.dlang.org/show_bug.cgi?id=23710

@WalterBright
Copy link
Member Author

Regression fix #14916

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.

6 participants