https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115379

            Bug ID: 115379
           Summary: -Wformat warning reports the wrong floating-point type
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gccbugs at dima dot secretsauce.net
  Target Milestone: ---

Hi. I have this program:

#include <stdio.h>
void tst(void)
{
    float x;
    scanf("%f", x);
}

I compile and I see this:

$ gcc-14 -Wall -Wextra -c -o tst2 tst2.c
tst2.c: In function 'tst':
tst2.c:5:13: warning: format '%f' expects argument of type 'float *', but
argument 2 has type 'double' [-Wformat=]
    5 |     scanf("%f", x);
      |            ~^   ~
      |             |   |
      |             |   double
      |             float *
...

Note that argument 2 has type "float", but the warning message says that it has
type "double". This is confusing. The actual bug is that it should be a
pointer, but it isn't.

This is gcc 14.1 from Debian version 14.1.0-1

Thanks
  • [Bug c/115379] New: -Wfor... gccbugs at dima dot secretsauce.net via Gcc-bugs

Reply via email to