www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20949] New: std.range.popFront is unsafe in release mode

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

          Issue ID: 20949
           Summary: std.range.popFront is unsafe in release mode
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Compile with `-release`:

----
import std.range.primitives: popFront;
import std.stdio: writeln;

void main()  safe
{
    char[3] a = "foo";
    int x = 42;

    char[] b = a[0 .. 0];
    b.popFront();
    b[3] = 13; /* Writes over x. */

    writeln(x); /* Prints "13". */
}
----

--
Jun 18