From 7e972dd8f8ecafbf2f181ac842e99ca9fdd5feba Mon Sep 17 00:00:00 2001 From: Dair Grant Date: Sun, 1 Mar 2020 00:25:59 +0000 Subject: [PATCH] Make underlying type of align_t / sign_t unsigned. When building with -Werror,-Wsigned-enum-bitfield clang reports that "enums in the Microsoft ABI are signed integers by default; consider giving the enum type an unsigned underlying type to make this code portable" for these two types. Under this ABI one bit of an enum bitfield is used by the sign bit. Enum values large enough to overlap that bit would be seen as negative integers if read out into an integer. There may not be any such reading out at present, but making the underlying type unsigned ensures consistent results across platforms. --- include/fmt/format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index ed87ea3d..cc8d267d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -997,12 +997,12 @@ template struct fill_t { // We cannot use enum classes as bit fields because of a gcc bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. namespace align { -enum type { none, left, right, center, numeric }; +enum type : uint8_t { none, left, right, center, numeric }; } using align_t = align::type; namespace sign { -enum type { none, minus, plus, space }; +enum type : uint8_t { none, minus, plus, space }; } using sign_t = sign::type;