[cfe-dev] -ftrapv
Chris Lattner
clattner at apple.com
Thu Apr 2 09:27:51 PDT 2009
On Apr 2, 2009, at 5:57 AM, David Chisnall wrote:
>>> You will need to use -ftrapu for SmallTalk. -ftrapv is for signed
>>> values only.
>>
>> FYI, it is completely inappropriate for Clang to support a -ftrapu
>> option for SmallTalk. Please remove this.
>
> I'm not sure I understand this comment. Smalltalk uses signed
> integers, so -ftrapv, not -ftrapu, is appropriate, but -ftrapu can
> be useful in a number of cases, for example in the implementation of
> calloc() which needs to multiply two size_t quantities together and
> check for overflow, and in any other situation involving computation
> of array offsets where some additional checks while debugging might
> be helpful.
>
> What makes the feature inappropriate? Some rationale, beyond 'FYI'
> would be helpful.
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.
-Chris
More information about the cfe-dev
mailing list