www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4465] New: ICE: assigning power to immutable in nested function

reply d-bugmail puremagic.com writes:
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



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: -------
Jul 15 2010
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jul 15 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
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                      |



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: -------
Aug 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4465


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Aug 13 2010
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Sep 22 2010