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

            Bug ID: 91809
           Summary: in c++ bit-field is not promoted to int in printf
                    argument
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

may be a -Wformat bug only, but the c++ front-end seems
to use the wrong type:

#include <stdio.h>

struct X {
  unsigned long long a: 1;
} x;

void foo()
{
  printf("%d", x.a);
}

gcc -Wformat -xc++  says

a.c: In function 'void foo()':
a.c:9:12: warning: format '%d' expects argument of type 'int', but argument 2
has type 'long long unsigned int' [-Wformat=]
    9 |   printf("%d", x.a);
      |           ~^   ~~~
      |            |     |
      |            int   long long unsigned int
      |           %lld

the warning is not present with -xc, which is
the expected behaviour: bit-field should be
promoted to int in this context, i don't think
c++ should behave differently.

(not a new regression, at least present since gcc-4.8)

Reply via email to