www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4961] New: ICE on Tuple in union as part of static struct member

reply d-bugmail puremagic.com writes:
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



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: -------
Sep 30 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4961


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Oct 05 2010
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Sep 16 2011