• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
help fixing overflow warning with abs()...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help fixing overflow warning with abs()...


  • Subject: help fixing overflow warning with abs()...
  • From: "Sean McBride" <email@hidden>
  • Date: Wed, 23 Dec 2009 10:36:49 -0500
  • Organization: Rogue Research Inc.

Hi all,

This code:

		int foo = ...;
		if (abs(foo) >= 1)

generates this warning:

"warning: assuming signed overflow does not occur when assuming abs (x)
>= 0 is true [-Wstrict-overflow]"

How would you resolve this?  Should abs() simply be avoided because of
the fact that abs(INT_MIN) returns INT_MIN?

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: help fixing overflow warning with abs()...
      • From: Clark Cox <email@hidden>
  • Prev by Date: Re: how to get signed/unsigned comparison warning with CLANG (and get rid of a spurious ; warning)
  • Next by Date: Re: help fixing overflow warning with abs()...
  • Previous by thread: Re: how to get signed/unsigned comparison warning with CLANG (and get rid of a spurious ; warning)
  • Next by thread: Re: help fixing overflow warning with abs()...
  • Index(es):
    • Date
    • Thread