checkedint call removal
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 2 11:55:24 PDT 2014
On 8/2/2014 8:08 AM, Andrei Alexandrescu wrote:
> On 8/2/14, 5:44 AM, Artur Skawina via Digitalmars-d wrote:
>> auto fx(ubyte* p, size_t len) @safe {
>> assert_(len>0);
>> if (len>=1)
>> return p[0];
>> return -1;
>> }
>
> As an aside I think it's a bug that this function passes @safe. It should not be
> able to safely dereference the pointer because it may be e.g. just past the end
> of the array. Has this been submitted as a bug? -- Andrei
>
There's more than one way to think about it. We could disable all pointer
dereferences, but another way is to fall back on the presumption that arguments
to @safe functions must themselves be valid.
I.e. is this @safe:
&array[length]
? How could a pointer past the end be created in @safe code?
More information about the Digitalmars-d
mailing list