Source-Changes-D archive

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

Re: CVS commit: src/games



On Sun, Mar 23, 2014 at 12:17:40AM +0000, David A. Holland wrote:
> Module Name:  src
> Committed By: dholland
> Date:         Sun Mar 23 00:17:40 UTC 2014
> 
> Modified Files:
>       src/games: Makefile.inc
> 
> Log Message:
> Add note cautioning against bothering with WARNS=6 until gcc improves
> (or -Wconversion is removed from WARNS=6) as it produces loads of false
> positives. The most entertaining of these that I've seen this afternoon:
> 
> games/hack/hack.apply.c:143:22: error: conversion to 'unsigned char:1' from 
> 'int' may alter its value [-Werror=conversion]
>    flags.move = multi = 0;

I agree.

If the compiler was doing some simple checks on the domain of the
value the it might be sensible, but otherwise is generates a lot
of false positives fo very little gain.

I dislike adding casts between integer types just to appease compiler
(and lint) warnings. They make the code unreadable and can hide
much more serious errors.

I'll live with -Wsign-compare even though that is sometimes painful.
Even then the compiler can 'know' that the signed variable never
contains a negative value - so need not emit a warning.

For instance with:
        for (int i = 0; i < sizeof foo; i++)
it can't matter that the comparison is unsigned because 'i' can be
assumed to be non-negative (even if 'sizeof foo' is greater than MAXINT).


        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index