[Issue 11908] New: const(char)[] assigned to immutable(char)[] without error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 12 09:25:52 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11908
Summary: const(char)[] assigned to immutable(char)[] without
error
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: turkeyman at gmail.com
--- Comment #0 from Manu <turkeyman at gmail.com> 2014-01-12 09:25:49 PST ---
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.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list