Thread overview
[Issue 1140] New: ICE casting tuple member to tuple struct
Apr 13, 2007
d-bugmail
Apr 13, 2007
d-bugmail
Apr 23, 2007
d-bugmail
[Issue 1140] ICE(cod1.c) casting last function parameter to struct.
May 19, 2009
Don
[Issue 1140] ICE(cod1.c) casting last function parameter to 8 byte value
Oct 07, 2009
Don
Oct 08, 2009
Don
Oct 13, 2009
Walter Bright
April 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1140

           Summary: ICE casting tuple member to tuple struct
           Product: D
           Version: 1.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


Useless bit of code, but it shouldn't ICE.

Internal error: ..\ztc\cod1.c 3282
-----------
struct Dog(B...)
{
    B values;
    static Dog!(B) create(B x) {
        return *cast(Dog!(B)*)(&x[1]);
    }
}

void main()
{
    auto c = Dog!(int, int).create(7,4);
}


-- 

April 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1140





------- Comment #1 from fvbommel@wxs.nl  2007-04-13 09:34 -------
*** Bug 1139 has been marked as a duplicate of this bug. ***


-- 

April 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1140


thomas-dloop@kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All




------- Comment #2 from thomas-dloop@kuehne.cn  2007-04-23 12:55 -------
Added to DStress as http://dstress.kuehne.cn/run/t/template_struct_09_A.d http://dstress.kuehne.cn/run/t/template_struct_09_B.d http://dstress.kuehne.cn/run/t/template_struct_09_C.d


-- 

May 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1140


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(cod1.c) casting tuple   |ICE(cod1.c) casting last
                   |member to tuple struct      |function parameter to
                   |                            |struct.




--- Comment #3 from Don <clugdbug@yahoo.com.au>  2009-05-19 00:27:41 PDT ---
Simpler test case shows that it's nothing to do with tuples! ICE on both D1 and D2.

struct Dog {
  int q;
  int r;
}
Dog hound(int y) {
    return *cast(Dog*)(&y);
}

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE(cod1.c) casting last    |ICE(cod1.c) casting last
                   |function parameter to       |function parameter to 8
                   |struct.                     |byte value


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2009-10-07 06:31:19 PDT ---
Even simpler test case shows it's nothing to do with structs! It just happens
when casting the last parameter, **which is passed in EAX, not on the stack**,
to an 8-byte value -- either an 8-byte struct or a long/ulong.
Although this code is legal, it's surely a bug. It would be OK for the compiler
to generate an error message.

long foo(int y) {
    return *cast(long*)(&y);
}

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


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

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


--- Comment #5 from Don <clugdbug@yahoo.com.au> 2009-10-07 23:58:13 PDT ---
This seems to be a superficial ICE. It only happens in this wierd situation,
when a parameter, which was passed in a register, needs to be stored into a
double-register (EDX:EAX).
In this case, the existing register can't be re-used, even though it satisfies
all the conditions in cod1 line 3433.
We simply need to add an extra condition to prevent the register being
re-used.After this simple change, correct code is generated instead of the ICE.
I think this case never occurs in the calling conventions used in DMC.

 Of course, taking the address of an parameter, then casting it to the wrong
size is a highly dubious thing
 to be doing, since it's getting whatever happens to be on the stack. Unsafe
mode only!

 PATCH (against DMD2.033) cod1.c, line 3434:

    // See if we can use register that parameter was passed in
    if (regcon.params && e->EV.sp.Vsym->Sclass == SCfastpar &&
-    regcon.params & mask[e->EV.sp.Vsym->Spreg])
+    regcon.params & mask[e->EV.sp.Vsym->Spreg] && sz!=REGSIZE*2)
    {    assert(sz <= REGSIZE);
    reg = e->EV.sp.Vsym->Spreg;
    forregs = mask[reg];
    mfuncreg &= ~forregs;
    regcon.used |= forregs;
    return fixresult(e,forregs,pretregs);
    }

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2009-10-13 13:43:47 PDT ---
Fixed dmd 1.049 and 2.034

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