[Bug libstdc++/69751] error: call of overloaded 'abs(size_t)' is ambiguous

2016-02-10 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69751

--- Comment #2 from Jonathan Wakely  ---
(In reply to mgans...@alice.de from comment #0)
> series.c:90:99: error: call of overloaded 'abs(size_t)' is ambiguous
> if (::abs(strlen(evtCompShortText) -
> strlen(episodeDb->getStrValue("COMPPARTNAME"))) >= dMin)
> 

This doesn't do what the author of that code thinks it does. If the second
string is longer than the first then the difference between them is not a
negative number, it's a huge unsigned value. Calling abs(int) on a huge
unsigned value will overflow and is undefined behaviour.

This is exactly why calling abs() here should be an error: the code has
undefined behaviour and should be fixed.

[Bug libstdc++/69751] error: call of overloaded 'abs(size_t)' is ambiguous

2016-02-10 Thread martin.gansser at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69751

--- Comment #3 from mgansser at alice dot de  
---
many thanks for supporting me, problem was solved.

[Bug libstdc++/69751] error: call of overloaded 'abs(size_t)' is ambiguous

2016-02-10 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69751

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||mpolacek at gcc dot gnu.org
 Resolution|--- |INVALID

--- Comment #1 from Marek Polacek  ---
This is invalid; calling abs() on an unsigned value does not make sense.
Cf. http://cplusplus.github.io/LWG/lwg-active.html#2192