D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6317 - ICE on struct literal of nested struct
Summary: ICE on struct literal of nested struct
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 critical
Assignee: No Owner
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2011-07-14 07:18 UTC by Heromyth
Modified: 2011-07-15 12:25 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Heromyth 2011-07-14 07:18:58 UTC
If "struct Relative" is defined at the outer of doTest(), everything is OK.

Here are the test codes:
=====================================
import std.stdio;

void doTest()
{
    struct Relative
    {
        int xBase;
        int xDir;

        // This method causes a compiler internal error
        void MoveTo()
        {
        }
    }

    Relative rel = {1, 2};
}

int main(string[] args)
{
    return 0;
}
=====================================
Comment 1 yebblies 2011-07-14 07:44:22 UTC
This fails for both kinds of struct initializers, Struct(...) and {...}.
Workaround is to use a static struct and pass the context as needed.

Thanks for reducing this!
Comment 2 yebblies 2011-07-14 09:13:52 UTC
Even simple workaround - use structname(args) instead of { args }.

https://github.com/D-Programming-Language/dmd/pull/253