digitalmars.D.bugs - [Issue 12980] New: Undefined behavior: Assignment of static string
- via Digitalmars-d-bugs (40/40) Jun 24 2014 https://issues.dlang.org/show_bug.cgi?id=12980
https://issues.dlang.org/show_bug.cgi?id=12980 Issue ID: 12980 Summary: Undefined behavior: Assignment of static string to dynamic string Product: D Version: D2 Hardware: x86_64 OS: Mac OS X Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: yuriy.glukhov gmail.com import std.stdio; char[10] getSomeString() { char[10] result; int i = 0; for (char a = '0'; a <= '9'; ++a) { result[i++] = a; } return result; } class A { this() { m = getSomeString(); } string m; } void main() { A a = new A(); writeln("STRING: ", a.m); // At this point a.m points to somewhere in stack and thus contains invalid value. } --
Jun 24 2014