C undefined behaviour

bearophile bearophileHUGS at lycos.com
Sat May 21 06:50:38 PDT 2011


Regarding what I have said here:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=136205

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:

http://comments.gmane.org/gmane.comp.compilers.clang.devel/4469

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


More information about the Digitalmars-d mailing list