[Issue 11888] New: Incorrect behaviour taking slice from return value
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 9 22:46:57 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11888
Summary: Incorrect behaviour taking slice from return value
Product: D
Version: D2
Platform: x86_64
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: turkeyman at gmail.com
--- Comment #0 from Manu <turkeyman at gmail.com> 2014-01-09 22:46:54 PST ---
So given a C-style function like this, that returns a pointer and length via
pointer argument:
ubyte* test(size_t* len)
{
*len = 100;
return cast(ubyte*)1234;
}
Call it, but immediately use the size argument to slice a range:
size_t size;
ubyte[] t = test(&size)[0..size];
t is null.
If I break it into separate statements, it works:
size_t size;
ubyte* pt = test(&size);
ubyte[] t = pt[0..size];
t.ptr = 1234, t.length = 100;
--
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