This is the mail archive of the gcc-bugs@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]

[Bug c/33873] New: Bad printf warning for bitfield


Consider this C code:

#include <stdio.h>

typedef long long int int64;
typedef long long unsigned int uint64;

struct pointer {
  uint64 data : 58;
  uint64 tag  : 6;
};


union value {
  int64 i;
  struct pointer p;
};

typedef union value Value;

void test(Value x) {
  printf("%llu\n", x.p.data);
}

When I compile it with -Wall, I get

foo.c:20: warning: format ?%llu? expects type ?long long unsigned int?, but
argument 2 has type ?long long unsigned int:58?

The value is presumably going to be passed to printf as an unsigned long
long--what else could it be passed as?  So this warning seems incorrect.

This may be related to PR 33819.


-- 
           Summary: Bad printf warning for bitfield
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33873


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