Pádraig Brady wrote:
> I noticed Jim fixed a couple obvious
> issues highlighted by the -Wsigned-compare gcc option
> we were talking about a few days ago.
> 
> The attached patch silences all other instances,
> so that this option may be used to help find these
> hard to spot errors, when they're introduced in future.
> 
> Note this patch is just for comment at this stage.
> Also note it is not tested on 64 bit.

Thinking more about this, shows a lot of casts are
to address the gcc warning:
"signed and unsigned type in conditional expression"

I don't see why gcc is giving this warning, as
there is no comparison between signed and unsigned here.
For example in the following program compiled
with -Wsign-compare why does the second assignment
give a warning, while the first doesn't?

#include <stdio.h>
#include <limits.h>

int main(void)
{
    int i=0;
    unsigned u=UINT_MAX;

    if (u)  i = u; /* no warning */
    i = u ? u : i; /* warning with -Wsign-compare */

    printf("%d\n", i);

    return 0;
}


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to