[llvm-bugs] [Bug 39369] New: -Wformat + typed enum class - difference with gcc

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 20 11:01:09 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39369

            Bug ID: 39369
           Summary: -Wformat + typed enum class - difference with gcc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/z/GX-Fqv

#include <stdio.h>

enum class Enum : unsigned short {
    One,
};

void test(Enum e) {
    printf("0x%04hx", e);
}

gcc:

<source>: In function 'void test(Enum)':
<source>:8:12: warning: format '%hx' expects argument of type 'int', but
argument 2 has type 'Enum' [-Wformat=]
     printf("0x%04hx", e);
            ^~~~~~~~~  ~
Compiler returned: 0

Clang is fine with that.

Who is wrong?

-- 
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/20181020/aa288cc0/attachment.html>


More information about the llvm-bugs mailing list