With the -Wformat option The code
void foo( float a )
give the warning:
foo.c:3: warning: format '%f' expects type 'double', but argument 2 has type 'float'
I believe this is unnecessary because float is promoted to double in variadic functions.
Works for me. Which target? Obviously you may need a prototype of printf
available for -Wformat to work at all.
Target is h8300-elf running on pc-windows or pc-cygwin
extern int printf( const char * fmt, ...);
Subject: Re: New: Incorrect printf warning: expect double has
6yxwfq202 at sneakemail dot com wrote:
> foo.c:3: warning: format '%f' expects type 'double', but argument 2 has type
> I believe this is unnecessary because float is promoted to double in variadic
Small 8/16 bit microprocessors often don't support all FP types.
h8300.h has for instance
#define FLOAT_TYPE_SIZE 32
#define DOUBLE_TYPE_SIZE 32
So floats and doubles are the same thing, which is probably confusing
something in the C front end. Maybe a type conversion got optimized
away (folded?) because it was a no-op for instance. I haven't tried to
Still present in 4.5 trunk, also fails for rx-elf-gcc with -m32bit-doubles but not with -m64bit-doubles.
Still fails for both h8300-elf and rx-elf, both on 4.5 branch and 4.6 trunk.
Created attachment 21866 [details]
FYI I've been using this to silence the warning in my local tree...
I have a deja vu
Subject: Re: Incorrect printf warning: expect double has float
On Wed, 22 Sep 2010, dj at redhat dot com wrote:
> ------- Comment #6 from dj at redhat dot com 2010-09-22 20:22 -------
> Created an attachment (id=21866)
> --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21866&action=view)
> possible fix
> FYI I've been using this to silence the warning in my local tree...
That's the wrong fix; instead, change convert_arguments to do the
conversion from float to double even if they have the same precision.
Why is this waiting? It only requires a fix.
*** Bug 46372 has been marked as a duplicate of this bug. ***
Iøm having the same isssue whne compiling with -fshort-double
printf( "%f", 2.0D );
will also produce the erroneous warning (tried on rx-elf)
Fixed with this patch: