[Bug libstdc++/69751] error: call of overloaded 'abs(size_t)' is ambiguous
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Feb 10 16:06:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69751
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to mgansser@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.
More information about the Gcc-bugs
mailing list