Skip to content

-Wformat + typed enum class - difference with gcc #38717

@LebedevRI

Description

@LebedevRI
Bugzilla Link 39369
Version trunk
OS Linux
CC @AaronBallman,@dwblaikie,@zygoloid

Extended Description

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

#include <stdio.h>

enum class Enum : unsigned short {
One,
};

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

gcc:

: In function 'void test(Enum)': :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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions