[Bug target/54686] std::abs (long long) resorts to std::abs (double) if llabs is absent

olegendo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Sep 23 21:51:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54686

--- Comment #11 from Oleg Endo <olegendo at gcc dot gnu.org> 2012-09-23 21:50:37 UTC ---
(In reply to comment #10)
> (In reply to comment #8)
> > Thanks god (or whoever)
> 
> Would that make me a half-god? seems dangerous...
> 
> > that the following:
> > 
> > unsigned int test_xx (unsigned int a)
> > {
> >   return std::abs (a);
> > }
> > 
> > ends up as a nop.  *phew*.
> 
> Try it with long (or long long) instead of int now...

You really scared me now.
unsigned long is also a nop.
unsigned short is also a nop.
unsigned char is also a nop.

*drumroll*

bool bleh (bool x)
{
  return std::abs (x);
}

gets a fine floating treatment -- it is converted to double and then tested for
!= 0.0.



More information about the Gcc-bugs mailing list