www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14017] New: Assignment of a mutable array returned from

https://issues.dlang.org/show_bug.cgi?id=14017

          Issue ID: 14017
           Summary: Assignment of a mutable array returned from non-`pure`
                    function to `immutable` global variable is allowed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com

This code compiles but shouldn't:
---
auto f() { return new int[1];  }

immutable s = f(); // error only with character arrays
---

Also such code is currently rejected for arrays of characters.

--
Jan 20 2015