www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2277] New: array ops and const arrays incompatible

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2277

           Summary: array ops and const arrays incompatible
           Product: D
           Version: 2.018
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: spam extrawurst.org


[CODE]
void main()
{
        const float[]   a;
        float[]         b;

        b[] = b[] + a[];        //works fine
        b[] += a[];             //compile error
}
[/CODE]

Compiler output (non conformant errors by the way, file,lines missing):

Error: 'c1' is not a scalar, it is a const(float)[]
Error: incompatible types for ((c1) += (p0[p])): 'const(float)[]' and
'const(float)'
Error: 'c1' is not of arithmetic type, it is a const(float)[]


-- 
Aug 10 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2277


Don <clugdbug yahoo.com.au> changed:

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





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: -------
Jun 08 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2277


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





13:33:55 PDT ---
Fixed dmd 2.032

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