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: [email protected]
Reporter: [email protected]
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.
}
--