Skip to content

[WIP] Fix Issue 18721 - ICE in dmd/cond.d(378) when compiling static foreach with -D#8128

Closed
wilzbach wants to merge 1 commit intodlang:masterfrom
wilzbach:fix-18721
Closed

[WIP] Fix Issue 18721 - ICE in dmd/cond.d(378) when compiling static foreach with -D#8128
wilzbach wants to merge 1 commit intodlang:masterfrom
wilzbach:fix-18721

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Apr 4, 2018

Okay, so yet another noobish attempt.
The ICE is caused by the invalid template never been instantiated and run through semantic.
DDoc, however, tries to inspect the template with getEponymousMember and thus obviously spectactuarly fails.

Has anyone a better idea to tackle this?

@dlang-bot
Copy link
Contributor

dlang-bot commented Apr 4, 2018

Thanks for your pull request, @wilzbach!

Bugzilla references

Auto-close Bugzilla Severity Description
18721 critical ICE in dmd/cond.d(378) when compiling static foreach with -D

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

To target stable perform these two steps:

  1. Rebase your branch to upstream/stable:
git rebase --onto upstream/stable upstream/master
  1. Change the base branch of your PR to stable

Testing this PR locally

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

dub fetch digger
dub run digger -- build "master + dmd#8128"

@wilzbach wilzbach changed the title Fix Issue 18721 - ICE in dmd/cond.d(378) when compiling static foreach with -D [WIP] Fix Issue 18721 - ICE in dmd/cond.d(378) when compiling static foreach with -D Apr 4, 2018
@dlang-bot dlang-bot added the Review:WIP Work In Progress - not ready for review or pulling label Apr 4, 2018
@jacob-carlborg
Copy link
Contributor

Is static foreach run before template instantiation?

@stefan-koch-sociomantic
Copy link

static foreach is supposed to be run as soon as possible.

@wilzbach static foreach can't be lowered`. I have no idea what you mean with that.

@wilzbach
Copy link
Contributor Author

wilzbach commented Apr 4, 2018

Is static foreach run before template instantiation?

AFAICT yes and that's the problem.:

core.exception.AssertError@dmd/cond.d(378): Assertion failure
----------------
??:? _d_assertp [0x74903d]
dmd/cond.d:378 pure nothrow @nogc @safe void dmd.cond.StaticForeach.prepare(dmd.dscope.Scope*).__require() [0x51392f]
dmd/cond.d:377 void dmd.cond.StaticForeach.prepare(dmd.dscope.Scope*) [0x5137dc]
dmd/attrib.d:1083 _ZN24StaticForeachDeclaration7includeEP5Scope [0x50c2df] <--- so we ended in an invalid static foreach block
dmd/doc.d:1042 _ZN11emitComment11EmitComment5visitEP17AttribDeclaration [0x55811b] <--- finds static foreach here and tries to resolve it

(the rest of the stack trace)

dmd/parsetimevisitor.d:75 _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP24StaticForeachDeclaration [0x6437f2]
dmd/attrib.d:1143 _ZN24StaticForeachDeclaration6acceptEP7Visitor [0x50c48d]
dmd/doc.d:1091 void dmd.doc.emitComment(dmd.dsymbol.Dsymbol, dmd.root.outbuffer.OutBuffer*, dmd.dscope.Scope*) [0x557798]
dmd/doc.d:796 void dmd.doc.emitMemberComments(dmd.dsymbol.ScopeDsymbol, dmd.root.outbuffer.OutBuffer*, dmd.dscope.Scope*) [0x55767c]
dmd/doc.d:916 _ZN11emitComment11EmitComment4emitEP5ScopeP7DsymbolPKc [0x557c57]
dmd/doc.d:960 _ZN11emitComment11EmitComment5visitEP11Declaration [0x557ded]
dmd/parsetimevisitor.d:47 _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP16AliasDeclaration [0x643492]
dmd/declaration.d:929 _ZN16AliasDeclaration6acceptEP7Visitor [0x535d61]
dmd/doc.d:1091 void dmd.doc.emitComment(dmd.dsymbol.Dsymbol, dmd.root.outbuffer.OutBuffer*, dmd.dscope.Scope*) [0x557798]
dmd/doc.d:796 void dmd.doc.emitMemberComments(dmd.dsymbol.ScopeDsymbol, dmd.root.outbuffer.OutBuffer*, dmd.dscope.Scope*) [0x55767c]
dmd/doc.d:439 _Z10gendocfileP6Module [0x556783]
dmd/mars.d:911 int dmd.mars.tryMain(ulong, const(char)**) [0x5f8097]

@wilzbach static foreach can't be lowered`. I have no idea what you mean with that.

Well, I would prefer an error from semantic like:

fail_compilation/fail18721.d(12): Error: undefined identifier T
fail_compilation/fail18721.d(18): Error: template instance `fail18721.allSameType!()` error instantiating

But the way I see this bug is that semantic never runs and DDoc still tries to resolve the invalid static foreach, so I improvised with the error message. I'm more than open to better ideas.

@jacob-carlborg
Copy link
Contributor

static foreach is supposed to be run as soon as possible.

I though it would be run at the same time as static if, which does not have this problem.

@wilzbach
Copy link
Contributor Author

wilzbach commented Apr 6, 2018

FTW I accidentally found another Bugzilla issues that segfault on the same line in the Json generator:

https://issues.dlang.org/show_bug.cgi?id=18581

///
template allSameType()
{
static foreach (idx; T)
Copy link
Member

Choose a reason for hiding this comment

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

The actual error looks like T is undefined.

@wilzbach
Copy link
Contributor Author

This has been fixed in master already. Closing.

@wilzbach wilzbach closed this Jun 27, 2018
@wilzbach wilzbach deleted the fix-18721 branch June 27, 2018 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:WIP Work In Progress - not ready for review or pulling Severity:Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants