Undefined behaviours in D and C

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Thu Apr 15 05:04:47 PDT 2010


bearophile wrote:
> Lars T. Kyllingstad:
> 
> Thank you for your answer & thread link.
> 
>> Some time ago, I believe Walter decided to let @safe mean "no undefined behaviour".
> 
> I find it hard to believe that safe modules can define for example the semantic of static casts between size_t and a pointer, while unsafe modules can leave it undefined as in C :-) To me this will lead to a mess even worse than the C situation.
> 
> So a better solution is to define such behaviours in both kinds of modules, or leave them undefined in both. I prefer the first possibility. And to make this happen a starting point is to list all things C standard leaves undefined.

The effect of @safe would be to forbid code that leads to undefined 
behaviour, not make it well-defined.

-Lars



More information about the Digitalmars-d mailing list