This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
- From: "egall at gwmail dot gwu.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 01 Aug 2016 12:13:59 +0000
- Subject: [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
- Auto-submitted: auto-generated
- References: <bug-63886-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63886
--- Comment #11 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Manuel López-Ibáñez from comment #10)
> (In reply to Eric Gallager from comment #8)
> > (In reply to Andreas Schwab from comment #4)
> > > float f = 3.1f;
> >
> > Isn't there already -Wunsuffixed-float-constants for warnings with that kind
> > of fix?
>
> -Wfloat-conversion is not warning about the lack of suffix, but about the
> fact that 3.1 does not fit into a double (3.5 does, so there is no warning).
>
> float f;
> double d;
>
> f = 3.100000000000000088817841970012523233890533447265625; //
> -Wfloat-conversion -Wunsuffixed-float-constants
> d = 3.100000000000000088817841970012523233890533447265625; //
> -Wunsuffixed-float-constants (not sure why!)
> f = 3.5; // -Wunsuffixed-float-constants
> d = 3.5; // -Wunsuffixed-float-constants (not sure why!)
> f = 3.1f; // no warning
> d = 3.1f; // no warning
About the ones where you wrote "(not sure why!)", it's asking the programmer to
add the nonstandard "d" suffix, which is a GNU extension. This has led projects
to ignore the warning:
https://lists.gnu.org/archive/html/bug-gzip/2011-11/msg00017.html
But I suppose that's an issue for a separate bug.