------- 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 #4 From Andrew Pinski 2007-06-21 09:06 [reply] ------- 
>>abs converts the float/double to an integer type so this is not a bug.  If you
>>use 4.3, you can use -Wconversion.

Notice that "b" and "d" are different - there is no (equal or otherwise)
"conversion".


The operation of abs (according to printf output) seems to be:

If it is an integer accept and use it. If it is a float then it is = 0 .

Look what printf does to "i", thats an easy conversion.
*/

#include <math.h>
#include <stdio.h>
int main ( ) { 
/* float a, b, c, d, e, f, g, h, i, j; */       /* gives warning "argument x
has type 'double'", it */
  double a, b, c, d, e, f, g, h, i, j;  /* might be better to say type "float"
instead */
  a = 16.000;
  b =  abs(a);
  c = fabs(a);
  d =  abs((int)(a));
  e = fabs((int)(a));
  f =  abs((float)(a));
  g = fabs((float)(a));
  h = (int)abs(a);
  i = (float)abs(a);
  j = 0.0;

  printf("a = %.2f  b = %.2f  c = %.2f  d = %.2f  e = %.2f  ", a, b, c, d, e);
  printf("f = %.2f  g = %.2f  h = %.2f  i = %.2f  j = %.2f\n", f, g, h, i, j);
  printf("a = %d  b = %d  c = %d  d = %d  e = %d  ", a, b, c, d, e);
  printf("f = %d  g = %d  h = %d  i = %d  j = %d\n", f, g, h, i, j);
  return 0;
}

/* /usr/test/bin/gcc -Wall -Wconversion -o math_test_7 math_test_7.c */

/* Output:
a = 16.00  b = 0.00  c = 16.00  d = 16.00  e = 16.00  f = 0.00  g = 16.00  h =
0.00  i = 0.00  j = 0.00
a = 0  b = 1076887552  c = 0  d = 0  e = 0  f = 0  g = 0  h = 0  i = 1076887552
 j = 0
*/

How can that be correct conversion ?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32448

Reply via email to