[Issue 4940] ICE(symbol.c): Accessing tuple-typed field of struct literal with user-defined constructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 6 01:35:02 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=4940



--- Comment #3 from Kenji Hara <k.hara.pg at 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: -------


More information about the Digitalmars-d-bugs mailing list