Undefined behaviours in D and C

Pelle pelle.mansson at gmail.com
Sun Apr 18 23:23:07 PDT 2010


On 04/18/2010 02:46 PM, Walter Bright wrote:
> Michel Fortin wrote:
>> So you shouldn't be able to cast a value to a pointer. The reverse,
>> casting a pointer to a value, makes sense in my opinion: you may want
>> to print the pointer value in a debug output of some sort. There's
>> nothing unsafe with that so it should be allowed.
>
> These are allowed in safe functions.

Just checking, this is allowed:

@safe void crash_maybe() {
     int* p = cast(int*)uniform(size_t.min, size_t.max);
     *p = 14;
}

right?



More information about the Digitalmars-d mailing list