lkml.org 
[lkml]   [2014]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: linux-next: build warning after merge of the tip tree
On 07/18/2014 01:08 PM, Andy Lutomirski wrote:
>
> i isn't an index in to the syms array at all. This code is completely
> wrong. See the patch I sent in reply to Stephen's original email.
>
> But, to your earlier point, presumably this could warn:
>
> for (int i = 0; i < 10; i++)
> if (array[i] > array[5] + 1)
> fail();
>
> I think that's absurd. There's nothing wrong with that code. A given
> test should have to be always true or always false on *all* loop
> iterations to be flagged, I think.
>

No, the issue is that gcc is telling you that the code will do the wrong
thing in this case. Yes, only for one iteration, but still.

The reason this is a concern is that: (x > x + n) and its variants is
often used to mean (x > INT_MAX - n) without the type knowledge, but
that is actually invalid standard C because signed types are not
guaranteed to wrap.

-hpa



\
 
 \ /
  Last update: 2014-07-19 09:21    [W:0.211 / U:0.472 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site