[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-
From: |
Eric Blake |
Subject: |
Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length |
Date: |
Tue, 29 Nov 2011 14:32:26 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 |
On 11/29/2011 02:27 PM, Paul Eggert wrote:
> On 11/29/11 13:18, Jim Meyering wrote:
>> Have you found code that triggers a -Wformat-zero-length warning
>> yet that doesn't seem worth adjusting?
>
> I haven't run into it one way or another, but all my instincts are
> against that diagnostic. I suspect that the most-common way that it
> would happen would be something like this admittedly-contrived example:
>
> #if FEATURE_ENABLED
> #define FEATURE_FORMAT "feature"
> #else
> #define FEATURE_FORMAT ""
> #endif
> ...
> printf (buf, FEATURE_FORMAT);
I assume you meant sprintf (buf, FEATURE_FORMAT), or printf
(FEATURE_FORMAT)?
>
> where the printf can be optimized away if FEATURE_ENABLED
> is zero, and the compiler is warning us about that.
Ah, but then I would use these more efficient idioms, which also avoids
the compiler warning:
puts (FEATURE_FORMAT) (replacing the printf case)
strcpy (buf, FEATURE_FORMAT) (replacing the sprintf case)
> This reminds me too much about bogus warnings that some compilers
> give for this:
>
> enum { N = FEATURE_ENABLED ? 1000 : 0 };
> ...
> for (i = 0; i < N; i++)
> foo (i);
>
> where the compiler proudly warns that it has optimized the loop
> away entirely, and did I really mean that? (Yes I did! and I don't
> want to be warned about it! :-)
I agree that a noisy compiler telling you about dead code due to
optimizations is a pain, but until we actually encounter the noise, I
can't say whether the signal-to-noise ratio warrants removing the
warning by default.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Paul Eggert, 2011/11/29
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Eric Blake, 2011/11/29
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Jim Meyering, 2011/11/29
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Eric Blake, 2011/11/29
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Eric Blake, 2011/11/29
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Simon Josefsson, 2011/11/30
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Jim Meyering, 2011/11/30
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Jim Meyering, 2011/11/30
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Paul Eggert, 2011/11/30
- Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length, Jim Meyering, 2011/11/30