Undefined behaviours in D and C

Walter Bright newshound1 at digitalmars.com
Fri Apr 16 22:46:04 PDT 2010


bearophile wrote:
> Walter Bright:
>> You won't be able to cast pointers from integral types in safe
>> functions.
> 
> That doesn't solve the problem, because I will surely want to use
> unsafe code in D, and unsafe modules will keep having the same
> undefined-derived bugs inherited from C. What I was asking for in
> this thread is to fix some of the C holes, not to just forbid the
> things I was looking for in D in the first place. If I use D instead
> of for example Python is because D has unions and pointers, that
> allow me to create the tight data structures that have a good
> performance. I am not interested in using D just as a Java.
> 
> This can be an irreducible difference between my ideal language and
> D. Maybe my purpose is  hopeless, who knows. My ideal system language
> is like a C that helps me avoid a large percentage of possible bugs.
> A language that the programmer can predict what it will do, with
> lower level features. Maybe someday I'll try to create this language
> :-)

I don't see any way to make conversions between pointers and ints 
implementation defined, and make dereferencing a pointer coming from 
some int anything but undefined behavior.




More information about the Digitalmars-d mailing list