This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The utility of standard's semantics for overflow


Dave Korn wrote:

  In fact, doesn't this suggest that in _most_ circumstances, *saturation*
would be the best behaviour?

Actually I think a handlable exception, a la Ada, is the best solution. Whether saturation is appropriate is really problem dependent. If you are counting the number of primes less than bla, then saturating is not likely to be helpful. If you are computing some real quantity with minimal precision, saturation might be helpful

And of course, since it's undefined, a compiler could entirely legitimately use saturating instructions (on a platform that supports them) for signed int arithmetic.

yes, of course, this would indeed be legitimate, and could be an option. Almost anything is reasonable as an option. I think it would be quite reasonable to have options for trapping (-ftrapv working nicely :-) and for wrap around. But I would not normally make either of these the default in C.

cheers, DaveK



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]