--- Comment #17 from ubizjak at gmail dot com 2007-06-23 19:51 ---
(In reply to comment #15)
> and here is the incorrect output:
Here is the correct input:
--cut here--
#include
int abs(int);
double fabs(double);
int main()
{
printf("%i %f %i %i\n", abs(1234.5678), fabs(1234.5
--- Comment #16 from ubizjak at gmail dot com 2007-06-23 19:41 ---
(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 work as "expected".
--
--- Comment #15 from rob1weld at aol dot com 2007-06-23 18:49 ---
>Andrew Pinski
>abs converts the float/double to an integer type so this is not a bug.
>Uros Bizjak
>The non-problem you are going after is in printf(). It takes variable arguments
>from the stack and interprets them acc
--- Comment #14 from kargl at gcc dot gnu dot org 2007-06-23 17:56 ---
(In reply to comment #13)
> (In reply to comment #11)
> > (1) Try -Wformat
>
> "-Wall" includes "-Wformat" according to gcc.info. See comment 7 for the
> command line I used:
> /* /usr/test/bin/gcc -Wall -Wconversion
--- Comment #13 from rob1weld at aol dot com 2007-06-23 08:32 ---
(In reply to comment #11)
> (1) Try -Wformat
"-Wall" includes "-Wformat" according to gcc.info. See comment 7 for the
command line I used:
/* /usr/test/bin/gcc -Wall -Wconversion -o math_test_7 math_test_7.c */
> (3) Th
--- Comment #12 from rob1weld at aol dot com 2007-06-23 07:51 ---
> Send a patch that implements your argflaps
Cyclone uses what it calls "thin" and "fat" pointers. We could implement this
in GCC. An extra byte per variable could store the type and a bit of code could
check it (at run-t
--- Comment #11 from kargl at gcc dot gnu dot org 2007-06-23 05:06 ---
(In reply to comment #10)
> (In reply to comment #9)
> > Don't worry, it works correctly.
> > ...
> > Argument are pushed to the stack by the caller without any other
> > communication with callee, so it is obvious th
--
rob1weld at aol dot com changed:
What|Removed |Added
Severity|minor |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32448
--- Comment #10 from rob1weld at aol dot com 2007-06-23 04:21 ---
(In reply to comment #9)
> Don't worry, it works correctly.
> ...
> Argument are pushed to the stack by the caller without any other
> communication with callee, so it is obvious that format string _must_
> reflect the ty
--- Comment #9 from ubizjak at gmail dot com 2007-06-22 12:26 ---
(In reply to comment #8)
> I'll work on some debugging and see if I can find out how it derives the value
> of "i" that it prints differently each time.
Don't worry, it works correctly.
The non-problem you are going aft
--- Comment #8 from rob1weld at aol dot com 2007-06-22 09:42 ---
A earlier version of this program had these lines in it:
...
f = abs((float)(a));
g = fabs((float)(a));
h = (int)abs(a);
i = 0.0;
printf("a = %.2f b = %.2f c = %.2f d = %.2f e = %.2f ", a, b, c,
--- Comment #7 from rob1weld at aol dot com 2007-06-22 09:18 ---
Uros Bizjak - has to include warnings about not drying animals in it
I have an older model with no such label therefore I am OK. ;)
--- Here is another program that demonstrates that there is some problem ---
/*
>>
--- Comment #6 from rob1weld at aol dot com 2007-06-21 11:30 ---
Thanks for everyones input.
The only issues related to this 'bug' are:
1): printf _sometimes_ prints "-0.000" and sometimes prints "+0.000" - the
reason it is even showing the "+" or "-" is because I enabled them using "
--- Comment #5 from ubizjak at gmail dot com 2007-06-21 11:27 ---
(In reply to comment #3)
> GCC printed no warning about disliking a conversion.
It just happens that gcc is not like microwave oven that has to include
warnings about not drying animals in it.
> Sometimes the answer is _
--- Comment #4 from pinskia at gcc dot gnu dot org 2007-06-21 09:06 ---
abs converts the float/double to an integer type so this is not a bug. If you
use 4.3, you can use -Wconversion.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32448
--- Comment #3 from rob1weld at aol dot com 2007-06-21 08:49 ---
GCC printed no warning about disliking a conversion.
I hacked the program in accordance with your suggestion and now it prints:
n= 4 QUESTION1=+0.123 QUESTION2=+0.123 Q(n)=+0.000
n= 5 QUESTION1=+0.099 QUESTION3=+0.0
--- Comment #2 from ubizjak at gmail dot com 2007-06-21 06:33 ---
Use fabs/fabsf for double/float operands. Especially with %f.
--
ubizjak at gmail dot com changed:
What|Removed |Added
---
--- Comment #1 from rob1weld at aol dot com 2007-06-21 06:01 ---
Created an attachment (id=13753)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13753&action=view)
Demo for abs / printf bug
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32448
18 matches
Mail list logo