[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [5275] Suppress gcc 4.x -Wpointer-sign (included in -Wa
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [5275] Suppress gcc 4.x -Wpointer-sign (included in -Wall) warnings |
Date: |
Tue, 28 Oct 2008 22:55:56 +0100 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080723) |
Andreas Färber wrote:
>
> Am 28.10.2008 um 17:54 schrieb Ian Jackson:
>
>> Blue Swirl writes ("[Qemu-devel] [5275] Suppress gcc 4.x
>> -Wpointer-sign (included in -Wall) warnings"):
>>> - ret = sprintf(phys_ram_base + (16 << 20) - 256,
>>> + ret = sprintf((char *)(phys_ram_base + (16 << 20) - 256),
>>
>> I realise I'm a bit late with this comment (my apologies), but:
>>
>> I think this shows that it would be better to suppress the warning
>> with the appropriate compiler option, than to try to update the code.
/me agrees.
>> And these kind of casts are dangerous because they can suppress
>> serious warnings about pointer/integer mismatch.
Exactly that's why.
> Not sure what type phys_ram_base had here, but char can be signed or
> unsigned depending on platform and this often leads to warnings on,
> e.g., OSX.
Pointer sign-ess for char is a PITA *because* just "char" can be signed
or unsigned depending on the platform. IIRC that is the reason the
linux kernel has the warning turned off.
> Suppressing all signedness warnings could hide real mistakes,
> too...
That is true too. Unfortunaly gcc has no -Wno-pointer-sign-char
cheers,
Gerd