[Issue 20949] New: std.range.popFront is unsafe in release mode

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 18 13:03:46 UTC 2020


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 at puremagic.com
          Reporter: ag0aep6g at 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". */
}
----

--


More information about the Digitalmars-d-bugs mailing list