[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please don't do this (code fragment)



On Tue, Jan 15, 2002 at 07:12:41PM -0600, Manoj Srivastava wrote:
> >>"elf" == elf  <elf@florence.buici.com> writes:
> 
>  elf> We aren't writing about unsigned arithmetic.
> 
> 	Since you seem to be protesting about people not being nice
>  and constructive, a few points of common courtesy called nettiquette:
>    a) Do not quote 85 lines to add only one of yours
>    b) Do not post your comment on the top followed by quoted material
>       below that. 

These are a matter of opinion.  When I write to you, I will endeavor
to follow your rules.

> 	To answer your dismissive nit: Overflow is a special case of
>  integer arithmetic (did you not express interest in INT_MAX +1? What
>  kind of expression do you think it is?). Given that the standard does
>  not speak directly of the result of overflow (except to say that it
>  results in undefined behaviour for signed integral values), any
>  insight into how integers need be implemented sheds light on the
>  issue. 

[deletia]

I don't think we disagree.  The standard does not appear to guarantee
that with *signed* integer arithmetic (int) MAX_INT + 1 < 0.  If there
is such a statement, please bring it forth and I will accept the
premise.  Otherwise, it is a matter of interpretation of the standard.
It appears possible that an implementer of the language could use
sign-bit arithmetic if there is a reason to do so.  That's all.  I
suspect that 99% of the compilers will make (int) MAX_INT + 1 < 0, but
because

  a) it is not guaranteed
  b) it is unnecessary to assume so

this whole thread becomes tedious.  Recall that this is about a piece
of code that makes this assumption as well as another (far worse one).

Please feel free to have the last word.

Cheers.



Reply to: