This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
printf format warning when sizeof(float) == sizeof(double)
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Wed, 10 Sep 2014 13:21:32 -0500
- Subject: printf format warning when sizeof(float) == sizeof(double)
- Authentication-results: sourceware.org; auth=none
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