[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looking for unsigned comparison warning
From: |
Grizlyk |
Subject: |
Re: Looking for unsigned comparison warning |
Date: |
Sat, 3 Mar 2007 11:46:32 +0300 |
mathieu wrote:
>
> I am looking for a flag that would warn me about someting like this
> (*). I have tried so far:
>
> $ g++ -Wall -Wextra -Wconversion -Wsign-compare -g unsigned.cxx
>
> Thanks
> -Mathieu
> (*)
> #include <iostream>
>
> unsigned int size()
> {
> return 0;
> }
>
> int main(int, char*[])
> {
> unsigned int s = size();
> unsigned int index = 1;
> if ( index <= s - 1 )
//if (!s) condition "if( index <= (s - 1) )" is always true
if(s) if ( index <= (s - 1) )
> {
> std::cout << index << " is valid for size " << s << std::endl;
> }
> return 0;
> }
>
- Re: Looking for unsigned comparison warning,
Grizlyk <=