← Back to index
|
Original Bugzilla link
Bug 11908 – const(char)[] assigned to immutable(char)[] without error
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-12T09:25:49Z
Last change time
2018-05-06T18:53:25Z
Assigned to
No Owner
Creator
Manu
Comments
Comment #0
by turkeyman — 2014-01-12T09:25:49Z
inout(char)[] todstr(inout(char)* cstr) pure nothrow { return cstr ? cstr[0 .. std.c.string.strlen(cstr)] : cstr[0 .. 0]; } struct Data { char buffer[256] = void; @property const(char)[] filename() const pure nothrow { return todstr(buffer.ptr); } } struct MyThing { private this(in Data* p) { filename = p.filename; // *** Uh oh! assigned a const(char)[] @property to a string! *** } string filename; } The const(char)[] is on the stack, program crashes soon after the assignment.