Friendly-C

via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 29 20:35:55 PDT 2014


On Friday, 29 August 2014 at 21:35:11 UTC, Marc Schütz wrote:
> "4. Reading from an invalid pointer either traps or produces an 
> unspecified value. In particular, all but the most arcane 
> hardware platforms can produce a trap when dereferencing a null 
> pointer, and the compiler should preserve this behavior."
>
> As I read it, they suggest that an invalid pointer access 
> should trap (but permit yielding an unspecified value).

"either" => it can produce an unspecified value without trapping.

(But Friendly-C is not a coherent spec, it is a blog post…)

> But still, taken together with point 4, it is debatable whether 
> trapping counts as "redundant or otherwise useless".

You have to look at the intended semantics of the program and how 
to make it correct. If loads and stores are meant to have side 
effects then it should be declared volatile, that is what 
"volatile" is for. (or use asm or an intrinsic with volatile 
semantics).


More information about the Digitalmars-d mailing list