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


--- 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: -------
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


--- 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: -------
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


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