[Issue 11240] New: assumeSafeAppend could implicitly break immutablity
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 12 23:49:54 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11240
Summary: assumeSafeAppend could implicitly break immutablity
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: druntime
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-12 23:49:53 PDT ---
I think assumeSafeAppend should reject array references which has non-mutable
element type.
Test case:
import std.stdio;
void main()
{
immutable(int[]) arr = [1,2,3];
immutable(int)[] a = arr[0..2];
writeln("a.capacity = ", a.capacity); // == 0
a = assumeSafeAppend(a[]);
writeln("a.capacity = ", a.capacity); // != 0
a ~= 100;
writeln(a); // [1, 2, 100]
writeln(arr); // [1, 2, 100] <-- !!
}
--
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