www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6317] New: A inner struct with member function causes a compiler internal error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6317

           Summary: A inner struct with member function causes a compiler
                    internal error
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bitworld qq.com



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;
}
=====================================

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6317


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Summary|A inner struct with member  |ICE on struct literal of
                   |function causes a compiler  |nested struct
                   |internal error              |
         OS/Version|Windows                     |All
           Severity|normal                      |critical



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!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6317


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



Even simple workaround - use structname(args) instead of { args }.

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6317


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



12:25:28 PDT ---
https://github.com/D-Programming-Language/dmd/commit/523a8c91a0761543a8757b99e3e3d9fe2fe993e2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 15 2011