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: Jim Meyering
Subject: Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length
Date: Wed, 30 Nov 2011 11:20:29 +0100

Simon Josefsson wrote:

> Paul Eggert <address@hidden> writes:
>
>> 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).
>>
>> 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.
>
> I'm opposed to this -- the philosophy behind the manywarnings module is
> to enable all possible kind of warnings that you can get from gcc and
> then each project has to disable the warnings that they decide are not
> worth fixing.  That decision has to be different for each project.  I
> believe this is fairly well described in doc/manywarnings.texi.
>
> I'm not opposed to create a somewarnings.m4 or similar that filters out
> some warnings, if you would find that useful.

Even -Wunsuffixed-float-constants has a use.
For example, I've just pushed this:

>From e6ac916bda3887c54cc8668be7a0936b034a28c3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 30 Nov 2011 09:35:00 +0100
Subject: [PATCH] hash: mark a few floating point constants with "f" suffix

* lib/hash.c (DEFAULT_GROWTH_THRESHOLD, DEFAULT_GROWTH_FACTOR)
(DEFAULT_SHRINK_THRESHOLD, DEFAULT_SHRINK_FACTOR): Mark literal
floating point constants with "f", since they're destined to be
saved/used as "float"s.
---
 ChangeLog  |    8 ++++++++
 lib/hash.c |    8 ++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 272dded..4d1c94c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-30  Jim Meyering  <address@hidden>
+
+       hash: mark a few floating point constants with "f" suffix
+       * lib/hash.c (DEFAULT_GROWTH_THRESHOLD, DEFAULT_GROWTH_FACTOR)
+       (DEFAULT_SHRINK_THRESHOLD, DEFAULT_SHRINK_FACTOR): Mark literal
+       floating point constants with "f", since they're destined to be
+       saved/used as "float"s.
+
 2011-11-29  Paolo Bonzini  <address@hidden>

        float tests: Correct and re-enable assertion about LDBL_MIN_EXP.
diff --git a/lib/hash.c b/lib/hash.c
index 1dd657a..0ee32d0 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -113,8 +113,8 @@ struct hash_table
    1.0).  The growth threshold defaults to 0.8, and the growth factor
    defaults to 1.414, meaning that the table will have doubled its size
    every second time 80% of the buckets get used.  */
-#define DEFAULT_GROWTH_THRESHOLD 0.8
-#define DEFAULT_GROWTH_FACTOR 1.414
+#define DEFAULT_GROWTH_THRESHOLD 0.8f
+#define DEFAULT_GROWTH_FACTOR 1.414f

 /* If a deletion empties a bucket and causes the ratio of used buckets to
    table size to become smaller than the shrink threshold (a number between
@@ -122,8 +122,8 @@ struct hash_table
    number greater than the shrink threshold but smaller than 1.0).  The shrink
    threshold and factor default to 0.0 and 1.0, meaning that the table never
    shrinks.  */
-#define DEFAULT_SHRINK_THRESHOLD 0.0
-#define DEFAULT_SHRINK_FACTOR 1.0
+#define DEFAULT_SHRINK_THRESHOLD 0.0f
+#define DEFAULT_SHRINK_FACTOR 1.0f

 /* Use this to initialize or reset a TUNING structure to
    some sensible values. */
--
1.7.8.rc4



reply via email to

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