On Thu, Apr 30, 2020 at 7:56 PM Thiago Macieira <
thi...@macieira.org> wrote:
>
> Code:
> #include <stdio.h>
>
> enum E1 {};
> enum E2 : unsigned char {};
> enum class E3 : unsigned char {};
>
> void f(E1 e) { printf("%d", e); }
> void f(E2 e) { printf("%d", e); }
> void f(E3 e) { printf("%d", e); }
>
> Godbolt:
https://gcc.godbolt.org/z/48QXdJ
> Note: Clang's warning on the third `f` is the crux of this problem.
>
> Note how GCC zero-extends for `E2` and ICC zero-extends for `E2` and `E3`, but
> Clang does for neither. (MSVC is there just because I had it open anyway)
>
> Should enum arguments when passed via `...` be zero extended?
>
> How about when not passing through `...`? See
https://gcc.godbolt.org/z/vLMfaX
> where GCC zero-extends the same way but now ICC does not.
>
> This may not be a bug anywhere if the ABI specifies that the only the low 8-
> bits are valid. In fact, if you add another overload with "unsigned char" as a
> parameter, GCC does zero-extend but Clang doesn't. But I can't find that
> wording in the document talking about zeror-extending or type promotion to
> int.
>