[Issue 9195] Can do pointer arithmetic in safeD!

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 30 17:26:32 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9195



--- Comment #5 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-12-30 17:26:28 PST ---
> Look again. It's not indexing an array, it's indexing a pointer.

Hmmm. Yes, you're right. It's indexing a pointer. I guess that that's currently
considered @safe, though underneath the hood, it's really no different from
pointer arithmetic. Dereferencing the pointer should be fine, and ptr[0] should
be fine for that same reason, but ptr[x] could be doing who-knows-what and
isn't really any different from *(ptr + x), so that should be considered
@system and isn't.

So, I'd say that the problem is that indexing a pointer is considered @safe
when it shouldn't be, presumably because it's not explicit pointer arithmetic.
The fact that you were talking about pointer arithmetic threw me off, since the
explicit pointer arithmetic _isn't_ @safe, and I guess that Walter got thrown
off in a similar way when he made pointer arithmetic @system.

-- 
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