November 13, 2023 [Issue 24242] New: forward inside templates with -dip1000 causes memory corruption | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24242 Issue ID: 24242 Summary: forward inside templates with -dip1000 causes memory corruption Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: d.bugs@webfreak.org minimal reproduction code: ```d // bug.d struct S() { ulong[] payload; this(ulong[] value) { import core.lifetime; payload = forward!value; } } S!() test() { return S!()([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); } void main() { import std.stdio; auto val = test().payload; writeln("[0]=", val[0], " (should be 0)"); writeln("[1]=", val[1], " (should be 1)"); writeln("[2]=", val[2], " (should be 2)"); writeln("[3]=", val[3], " (should be 3)"); writeln("[4]=", val[4], " (should be 4)"); writeln("[5]=", val[5], " (should be 5)"); writeln("[6]=", val[6], " (should be 6)"); writeln("[7]=", val[7], " (should be 7)"); writeln("[8]=", val[8], " (should be 8)"); writeln("[9]=", val[9], " (should be 9)"); } ``` `dmd -dip1000 -run source/app.d` (also happening with LDC) causes: ``` [0]=0 (should be 0) [1]=1 (should be 1) [2]=140720508484016 (should be 2) [3]=140720508484400 (should be 3) [4]=14 (should be 4) [5]=94655388051378 (should be 5) [6]=94655388051378 (should be 6) [7]=7 (should be 7) [8]=4 (should be 8) [9]=94655388051453 (should be 9) ``` real-world code: assign a `string[]` to mir-core's `Algebraic!(string[])`, the strings will be messed up note that everything works as expected without -dip1000 -- |
Copyright © 1999-2021 by the D Language Foundation