Thread overview
[Issue 4940] New: ICE(symbol.c): Accessing tuple-typed field of struct literal with user-defined constructor
Sep 26, 2010
Kasumi Hanazuki
Aug 30, 2011
yebblies
Aug 30, 2011
yebblies
Jan 06, 2012
Kenji Hara
Jan 06, 2012
Kenji Hara
Jan 06, 2012
Kenji Hara
Jan 06, 2012
Kenji Hara
Jan 17, 2012
Walter Bright
September 26, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4940

           Summary: ICE(symbol.c): Accessing tuple-typed field of struct
                    literal with user-defined constructor
           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: k.hanazuki@gmail.com


--- Comment #0 from Kasumi Hanazuki <k.hanazuki@gmail.com> 2010-09-25 18:39:51 PDT ---
DMD v2.049 on Windows crashes with the message:

  Internal error: ..\ztc\symbol.c 1043

This only occurs when accessing a tuple-typed field on a struct literal directly and using an user-defined constructor.

----

void main() {
  auto w = S(0).x;
}

template Tuple(T...) {
  alias T Tuple;
}

struct S {
  Tuple!(int, int) x;
  this(int) { }
}

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


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha@yahoo.com


--- Comment #1 from yebblies <yebblies@gmail.com> 2011-08-30 15:13:26 EST ---
*** Issue 6530 has been marked as a duplicate of this issue. ***

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


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #2 from yebblies <yebblies@gmail.com> 2011-08-30 15:13:59 EST ---
Test case from 6530:

struct S {
    int a, b, c;
}

struct HasPostblit {
    this(this) {}  // Bug goes away without this.
}

auto toRandomAccessTuple(T...)(T input, HasPostblit hasPostblit) {
    return S(1, 2, 3);
}

void doStuff(T...)(T args) {
    HasPostblit hasPostblit;

    // Bug goes away without the .tupleof.
    auto foo = toRandomAccessTuple(args, hasPostblit).tupleof;
}

void main() {
    doStuff(1, 2, 3);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4940



--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-06 01:34:59 PST ---
In the expression e1.tupleof, if e1 has some side effect, this problem occurs.

The explanation of bug mechanism:

1. e1.tupleof is translated to e1.field0, e1.field1, ..., e1.fieldN
(e1.tupleof.length == N).
But if e1 has some side effect (e.g. e1 is function call), e1 is simply
duplicated.

  funcall().tupleof -> (funcall().field0, funcall, field1, ..., funcall.fieldN)

2. Postblit call on function argument creates hidden temporary variable.

  toRandomAccessTuple(args, hasPostblit)
  ->
  toRandomAccessTuple(args, (auto __cpcttmp = hasPostblit, __cpcttmp))

The combination of #1 and #2 causes duplication of hidden variable like follows:

  toRandomAccessTuple(args, hasPostblit).tupleof
  ->
  (toRandomAccessTuple(args, (auto __cpcttmp = hasPostblit, __cpcttmp)).a,
   toRandomAccessTuple(args, (auto __cpcttmp = hasPostblit, __cpcttmp)).b,
   toRandomAccessTuple(args, (auto __cpcttmp = hasPostblit, __cpcttmp)).c)

Finally the repetation of __cpcttmp cause ICE in backend.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4940


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-06 01:36:27 PST ---
*** Issue 6729 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4940



--- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-06 01:36:43 PST ---
*** Issue 7233 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4940


Kenji Hara <k.hara.pg@gmail.com> changed:

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


--- Comment #6 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-06 02:34:55 PST ---
https://github.com/D-Programming-Language/dmd/pull/609

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4940


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2012-01-17 11:05:29 PST ---
https://github.com/D-Programming-Language/dmd/commit/d6ede2edc28c94b6b3372eb1301cf300b0860eb6

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