Skip to content

Commit 133b171

Browse files
smeenaifacebook-github-bot
authored andcommitted
Fix -Wformat with Clang 17
Summary: Clang 17 requires an explicit cast when using an `enum class` with `printf` to not trigger `-Wformat`. Reviewed By: JacobSzwejbka Differential Revision: D49524519 fbshipit-source-id: 7779d4fffebb73856997d14b4a189e74266f8e18
1 parent c3f3ef4 commit 133b171

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

runtime/core/exec_aten/util/scalar_type_util.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ inline size_t elementSize(exec_aten::ScalarType t) {
289289
switch (t) {
290290
ET_FORALL_SCALAR_TYPES(CASE_ELEMENTSIZE_CASE)
291291
default:
292-
ET_CHECK_MSG(false, "Unknown ScalarType %hhd", t);
292+
ET_CHECK_MSG(false, "Unknown ScalarType %" PRId8, static_cast<int8_t>(t));
293293
}
294294
#undef CASE_ELEMENTSIZE_CASE
295295
}
@@ -552,8 +552,8 @@ inline size_t sizeof_scalar_type(exec_aten::ScalarType type) {
552552
type != exec_aten::ScalarType::ComplexDouble &&
553553
type != exec_aten::ScalarType::BFloat16 &&
554554
type != exec_aten::ScalarType::Undefined,
555-
"Invalid or unsupported ScalarType %hhd",
556-
type);
555+
"Invalid or unsupported ScalarType %" PRId8,
556+
static_cast<int8_t>(type));
557557

558558
size_t type_size = 0;
559559
#define SCALAR_TYPE_SIZE(ctype, dtype) \
@@ -564,7 +564,8 @@ inline size_t sizeof_scalar_type(exec_aten::ScalarType type) {
564564
switch (type) {
565565
ET_FORALL_SCALAR_TYPES(SCALAR_TYPE_SIZE)
566566
default:
567-
ET_CHECK_MSG(false, "Invalid input ScalarType %hhd", type);
567+
ET_CHECK_MSG(
568+
false, "Invalid input ScalarType %" PRId8, static_cast<int8_t>(type));
568569
}
569570
#undef SCALAR_TYPE_SIZE
570571

0 commit comments

Comments
 (0)