On 10.09.2012 19:08, Benjamin Thaut wrote:
> The following code
>
>
> bool endsWith(string str, string end)
> {
>      size_t to = str.length - end.length;
>      for(sizediff_t i = str.length - 1; i >= to; --i)

Unfortunately, unsigned takes precedence over signed in any calculation, so "i >= to" is an unsigned comparison, where i is converted to unsigned first.

A lot of calculation that involve size_t and implicite conversions or substractions are pretty error-prone.

Reply via email to