www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: C undefined behaviour

reply bearophile <bearophileHUGS lycos.com> writes:
This follows:

Third part and last one:

This third article gives possible ideas for future safety improvements of D
design :-) Every time you fix/avoid some of those problems, you erode away some
costly and sometimes painful debugging time. So this work is ethically sound

May 21 2011
parent bearophile <bearophileHUGS lycos.com> writes:
Regarding what I have said here:

A person has said me that Clang had the -ftrapu compiler switch to trap
unsigned overflow too, but Chris removed it, because unsigned overflow is
defined in the C standard. The discussion:


The comment by Chris Lattner:

 I'm sorry I was too terse.  I don't want clang IR generation  
 supporting language features that are not useful for C/C++ etc.   
 Previously we had run-ins where you were trying to adapt the objc  
 runtime generation code to work with your objective-smalltalk  
 compiler, and this was causing the code to get contorted and be slow.
 I don't think it is ever a good idea to turn random unsigned  
 multiplies into overflow checked ones, so I don't think that -ftrapu  
 is useful for C programmers, so I think it should be removed.
 I *would* be supportive of an attribute on integer types that let  
 programmers "opt in" to overflow checking on particular values.  This  
 would be incredibly cool and generally useful because it doesn't break  
 the semantics of C.  I just am opposed to a global option that changes  
 how C works.

D doesn't need to follow such C design decisions. And even for C, Chris has broken and improved over some sclerotic design decisions of C compiler designers (even on little things, like Clang doesn't need a switch to compile C99 code!). So probably the generation of compiler writers successive to Chris will improve further. Compiler technology seems to move forward about ten times slower than other computer technology :-) Bye, bearophile
May 21 2011