[Issue 2277] array ops and const arrays incompatible

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 8 16:23:24 PDT 2009


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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code, patch
         AssignedTo|nobody at puremagic.com        |bugzilla at digitalmars.com




--- Comment #1 from Don <clugdbug at yahoo.com.au>  2009-06-08 16:23:23 PDT ---
This might as well be an ICE, since the error messages refer to internally
generated code, and have no line number.
Applies to all binary arithmetic and logical array operations.
Root cause: cast.c, When e2 is const, and e1 is mutable, typeMerge() transforms 
e1 OP= e2 into (cast(const)(e1)) OP= e2.
That's appropriate for +, but not for +=. We only need to check that the
operation is legal, no cast should be performed.

PATCH: cast.c, typeMerge(), around line 1532:
    else if ((t1->ty == Tsarray || t1->ty == Tarray) && t1->implicitConvTo(t2))
    {
+        // Don't actually convert if it's an array operation
+        if (e->op == TOKaddass || e->op == TOKminass 
+            || e->op == TOKmulass || e->op == TOKdivass 
+            || e->op == TOKandass ||e->op == TOKorass || e->op == TOKxorass)
goto Lret;
    goto Lt2;
    }

-- 
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