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

            Bug ID: 87667
           Summary: -Wformat + typed enum class - difference with clang
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lebedev.ri at gmail dot com
  Target Milestone: ---

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?

Reply via email to