Thread overview
[Issue 4961] New: ICE on Tuple in union as part of static struct member
Sep 30, 2010
Simen Kjaeraas
Oct 05, 2010
Don
[Issue 4961] ICE(interpret.c) Tuple in union as part of static struct member
Sep 16, 2011
Simen Kjaeraas
September 30, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4961

           Summary: ICE on Tuple in union as part of static struct member
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: simen.kjaras@gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-09-30 12:52:16 PDT ---
The below code crashes DMD with the following message:

Assertion failure: 'existing->op == TOKstructliteral' on line 2090 in file 'interpret.c'

abnormal program termination


////////////////////////////

import std.typecons;

struct bar {
    static bar b = bar( 0 );

    union {
        int[1] value;
        Tuple!( int ) fields;
    }

    this( int r ) {
        fields.expand[0] = r;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4961


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-10-05 01:56:06 PDT ---
Reduced test case shows it doesn't require tuples.

struct Fields4961 { int x; }
struct bar4961 {
    union {
       int[1] value;
       Fields4961 fields;
    }

    this( int r ) {
       fields.x = r;
    }
}
static bar4961 b4961 = bar4961( 0 );

Interestingly, if you swap 'value' and 'fields', you get an error message with no line number:

Error: duplicate union initialization for value

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 16, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4961


Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-09-16 08:57:00 PDT ---
This example has been reduced to a limitation of CTFE. The original problem is gone. The below code works as expected:

struct Fields4961 { int x; }
struct bar4961 {
    union {
       int[1] value;
       Fields4961 fields;
    }

    this( int r ) {
       fields.x = r;
    }
}
static bar4961 b4961; // No longer initialized here. No CTFE problems.

static this( ) {
    b4961 = bar4961( 0 );
}

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