This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

printf format warning when sizeof(float) == sizeof(double)


Hi

We have a few RTEMS BSPs which use CPUs where float, double,
and long double are the same.  This triggers the printf format
warning because promoting float to double results in float.
At least that's what I think is happening. This happens on at
least the h8sx and sh2e.

$ h8300-rtems4.11-gcc -c -Os -Wall -msx warnf.c
warnf.c: In function 'f':
warnf.c:5:3: warning: format '%f' expects argument of type 'double', but
argument 2 has type 'float' [-Wformat=]
   printf( "%f", X );
   ^
warnf.c:5:3: warning: format '%f' expects argument of type 'double', but
argument 2 has type 'float' [-Wformat=]

The code is:

#include <stdio.h>

void f(float X)
{
  printf( "%f", X );
}

Any ideas? Should I raise a PR?

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]