[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Looking for unsigned comparison warning

From: Bernd Strieder
Subject: Re: Looking for unsigned comparison warning
Date: Mon, 05 Mar 2007 12:56:08 +0100
User-agent: KNode/0.10.4

mathieu wrote:

> Hello,
>   I am looking for a flag that would warn me about someting like this
> (*). I have tried so far:

I don't think that there is a warning, because AFAIK wrap around is the
only option for chip and compiler makers not killing performance in the
known safe cases. I'm not fully sure, but I think that there has been
some recent discussion about even mandating wrap-around.

The right thing to do would be correcting the source code

>   if ( index <= s - 1 )

if (index < s)

avoiding all problems, and following the C++ iterator range idiom. s==0
means never true, instead of always true as before. All occurences of
<= in index or iterator comparisions are suspicious.

Bernd Strieder

reply via email to

[Prev in Thread] Current Thread [Next in Thread]