[cfe-dev] -ftrapv

David Chisnall csdavec at swan.ac.uk
Thu Apr 2 09:48:33 PDT 2009


On 2 Apr 2009, at 17:27, Chris Lattner wrote:

> 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'm not using -ftrapu, so I don't have any personal problems with it  
being removed, although, as I said, I can imagine some (hypothetical)  
cases where it would be useful for debugging.

> 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.

I definitely agree.  The existing code is designed with exactly this  
in mind.  Replacing all potentially-overflowing operations was simply  
the easiest way of testing it (my initial version of -ftrapv checked  
signed and unsigned values, Mike split the checks into -ftrapv for  
signed and -ftrapu for unsigned).  I hope to progressively make this  
finer-grained, but per-file seemed like a good first step.

David



More information about the cfe-dev mailing list