Thread overview
[Issue 4465] New: ICE: assigning power to immutable in nested function
[Issue 4465] ICE: assigning power to immutable and returning result
[Issue 4465] ICE: immutable type inference with ^^2
Aug 13, 2010
Don
[Issue 4465] ICE(symbol.c): immutable type inference with ^^2
Aug 13, 2010
Don
Sep 23, 2010
Walter Bright
July 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4465

           Summary: ICE: assigning power to immutable in nested function
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bugzilla@kyllingen.net


--- Comment #0 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-07-15 06:41:42 PDT ---
Test case:

    void f()
    {
        int g()
        {
            immutable z = 2^^2;  // or const, doesn't matter
            return z;
        }
    }

Error:

    Internal error: ../ztc/symbol.c 1041

The error message disappears if you
    - make g() return something other than z
    - make z mutable
    - assign z something other than a power expression

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4465


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE: assigning power to     |ICE: assigning power to
                   |immutable in nested         |immutable and returning
                   |function                    |result


--- Comment #1 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-07-15 08:40:25 PDT ---
Turns out this has nothing to do with the function being nested.  This fails too, with the same error:

    int g()
    {
        immutable z = 2^^2;
        return z;
    }

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au
            Summary|ICE: assigning power to     |ICE: immutable type
                   |immutable and returning     |inference with ^^2
                   |result                      |


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-08-13 03:03:40 PDT ---
Reduced test case. Doesn't even need a return. It only happens for x^^2 and x^^3,  and that's because those cases become comma expressions. Probably something is wrong in fromConstInitializer().

void bug4465()
{
    const a = 2 ^^ 2;
    int b = a;
}

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


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

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


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2010-08-13 12:15:34 PDT ---
One option would be to change PowExp to stop using CommaExp, but I think that lowering involving comma expressions is such a useful internal feature that it's worth supporting.
---------------
PATCH:
optimize.c, fromConstInitializer(), line 142.

        e = expandVar(result, v);
        if (e)
        {
+            // If it is a comma expression involving a declaration, we mustn't
+            // perform a copy -- we'd get two declarations of the same
variable.
+            // See bugzilla 4465.
+            if (e->op == TOKcomma && ((CommaExp *)e)->e1->op ==
TOKdeclaration)
+                 e= e1;
+            else
        if (e->type != e1->type && e1->type && e1->type->ty != Tident)
            {   // Type 'paint' operation
                e = e->copy();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 23, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4465


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2010-09-22 17:44:54 PDT ---
http://www.dsource.org/projects/dmd/changeset/685

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