[llvm-bugs] [Bug 30533] New: -Wformat check is not correct when using bitfield parameters

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 26 21:22:25 PDT 2016


            Bug ID: 30533
           Summary: -Wformat check is not correct when using bitfield
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arichardson.kde at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

I noticed that one of my printfs was outputting garbage values even though I
compile with -Werror=format.

Abbreviated example:

struct foo {
  uint64_t a : 10;
  uint64_t b : 12;
  uint64_t c : 10
foo f;
f.b = 0xab;

printf("Foo.b: %llx", f.b);

This usually gave me random garbage like Foo.b:7fa0000000ab (always with the
correct value at the end). It seems to me that the f.b is being passed as a 32
bit int on the stack but because it is declared as a uint64_t bitfield the
-Wformat check assumes that %llx is okay.

clang --version
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160927/eae0e3cb/attachment.html>

More information about the llvm-bugs mailing list