This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git
The following commit(s) were added to refs/heads/main by this push:
new 5fba9e8 [COMPILE] Fixed error compile when using compiler gcc 8.x
(#85)
5fba9e8 is described below
commit 5fba9e8ff31940855b4abfa664c3369513814aa4
Author: Nguyen Duy Loc <[email protected]>
AuthorDate: Sat Oct 4 01:09:46 2025 +0700
[COMPILE] Fixed error compile when using compiler gcc 8.x (#85)
Co-authored-by: Tianqi Chen <[email protected]>
---
include/tvm/ffi/type_traits.h | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/include/tvm/ffi/type_traits.h b/include/tvm/ffi/type_traits.h
index 0f19719..0fce70b 100644
--- a/include/tvm/ffi/type_traits.h
+++ b/include/tvm/ffi/type_traits.h
@@ -301,11 +301,22 @@ struct TypeTraits<Int,
std::enable_if_t<std::is_integral_v<Int>>> : public TypeT
TVM_FFI_INLINE static std::string TypeStr() { return
StaticTypeKey::kTVMFFIInt; }
};
+/// \cond Doxygen_Suppress
+
+// trait to check if a type is an integeral enum
+// note that we need this trait so we can confirm underlying_type_t is an
integral type
+// to avoid potential undefined behavior
+template <typename T, bool = std::is_enum_v<T>>
+constexpr bool is_integeral_enum_v = false;
+
+template <typename T>
+constexpr bool is_integeral_enum_v<T, true> =
std::is_integral_v<std::underlying_type_t<T>>;
+
+/// \endcond
+
// Enum Integer POD values
template <typename IntEnum>
-struct TypeTraits<IntEnum, std::enable_if_t<std::is_enum_v<IntEnum> &&
-
std::is_integral_v<std::underlying_type_t<IntEnum>>>>
- : public TypeTraitsBase {
+struct TypeTraits<IntEnum, std::enable_if_t<is_integeral_enum_v<IntEnum>>> :
public TypeTraitsBase {
static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIInt;
TVM_FFI_INLINE static void CopyToAnyView(const IntEnum& src, TVMFFIAny*
result) {