[Issue 11176] New: array.ptr in @safe code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 5 11:29:37 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11176
Summary: array.ptr in @safe code
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: code at klickverbot.at
--- Comment #0 from David Nadlinger <code at klickverbot.at> 2013-10-05 11:29:36 PDT ---
The following program is @safe, yet reads from an invalid memory location:
---
@safe:
ubyte oops(ubyte[] b) {
return *b.ptr;
}
void main() {
oops(new ubyte[0]);
// - or -
auto b = new ubyte[42];
oops(b[$ .. $]);
}
---
To keep memory safety guarantees, we would at least have to make sure that the
element after the end of an array never belongs to a different, valid
allocation.
Brought up by Denis Shelomovskij in a discussion on GitHub.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list