bug-gnulib
[Top][All Lists]
Advanced

[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:19:42 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

On 11/29/2011 02:05 PM, Paul Eggert wrote:
> On 11/29/11 09:35, Jim Meyering wrote:
>> +  gl_WARN_ADD([-Wno-unsuffixed-float-constants])
> 
> How about if we remove -Wunsuffixed-float-constants from
> manywarnings.m4?  In practice it typically causes more
> trouble than it cures (the above-quoted gzip patch is
> one example, but I've run into it elsewhere).

I've seen -Wunsuffixed-float-constants trigger in a couple projects now,
so it really is a new warning that pops up on existing code; but it's
also fairly mechanical to correct (for example, while fixing it for
libvirt, I found at least one case where it was sufficient to use int
instead of floating point).

I'm not convinced about removing it from manywarnings.m4 - it's not that
hard to disable the warning if you don't want it, but leaving it in
leads to smaller executable size for the cases where 1.0F is sufficient
(compared to the extra size required to represent 1.0 which is 1.0D).
By explicitly marking F or D to all float constants, it shows you've
thought about which precision is worth using; omitting the suffix could
be the sign of sloppy code that has other problems with misuse of
floating point.

> 
> While we're on the subject of manywarnings.m4, can we also
> remove -Wdouble-promotion and -Wformat-zero-length?  They
> also seem to be more suited for special- rather than
> general-purpose code.

Do you have instances in the wild where these triggered?  I haven't seen
either one trigger, and it's hard to say that removing it is worthwhile
without an idea of what it is protecting against, and whether the
protection flies in the face of common programming idioms to actually
make the warning useful only in specific coding styles.

Meanwhile, while we are on the topic, I got tripped up by the fact that
-Wformat=2 (newly added to manywarnings.m4) implies -Wformat-nonliteral,
even though libvirt had already been explicitly removing
-Wformat-nonliteral from the list of desired warnings.  I had to add
-Wno-format-nonliteral to counteract that, while still benefitting from
the rest of -Wformat=2.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]