--- Comment #23 from pinskia at gcc dot gnu dot org 2007-06-28 18:51
---
There is a -Wformat for a reason, use it.
--
pinskia at gcc dot gnu dot org changed:
What|Removed |Added
--- Comment #21 from rob1weld at aol dot com 2007-06-24 12:22 ---
(In reply to comment #20)
Since GCC can 'see' the %f at compile time
... that does not mean the behavior is the correct to cast it to float. ...
So the correct behavior is:
a): Cast it to something other than float.
--- Comment #18 from rob1weld at aol dot com 2007-06-24 03:21 ---
(In reply to comment #16)
(In reply to comment #14)
m.c: In function 'main':
m.c:9: warning: implicit declaration of function 'abs'
Also, add a prototype for integer abs(), like int abs(int);. Then everything
will
--- Comment #19 from rob1weld at aol dot com 2007-06-24 05:01 ---
So here we have it:
#include stdio.h
int abs(int);
double fabs(double);
int main()
{
printf(%f %f %f %f\n, abs(1234.5678), fabs(1234.5678),
abs((int)1234.5678), abs((int)(1234.5678)));
printf(%f %f %f
--- Comment #20 from pinskia at gcc dot gnu dot org 2007-06-24 05:08
---
Since GCC can 'see' the %f at compile time
Yes it can but that does not mean the behavior is the correct to cast it to
float. In fact the behavior is undefined at runtime so you are just running
into the runtime