Skip to content

Commit

Permalink
avoid assumption on underlying type of unscoped enum in simd traits
Browse files Browse the repository at this point in the history
Summary: The underlying type of an unscoped `enum` is specified as implementation-defined. Avoid assuming what it is. In practice, msvc appears to choose `unsigned int` while gcc and clang choose `signed int`.

Differential Revision: D64644008

fbshipit-source-id: 97fcc81be1fa23447c3c9d502c9874c1947f710b
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Oct 20, 2024
1 parent 836cbfd commit a6e3b26
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions folly/algorithm/simd/detail/test/TraitsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ static_assert(
std::is_same_v<double, simd_friendly_equivalent_scalar_t<double>>);

// enum
enum SomeInt {};
enum class SomeIntClass : std::int32_t {};

static_assert(
std::is_same_v<std::uint32_t, simd_friendly_equivalent_scalar_t<SomeInt>>);
static_assert(std::is_same_v<
std::int32_t,
simd_friendly_equivalent_scalar_t<SomeIntClass>>);
enum SomeInt : std::int16_t {};
enum class SomeIntClass : std::uint32_t {};

static_assert( //
std::is_same_v< //
std::int16_t,
simd_friendly_equivalent_scalar_t<SomeInt>>);
static_assert( //
std::is_same_v<
std::uint32_t,
simd_friendly_equivalent_scalar_t<SomeIntClass>>);

// const

Expand Down

0 comments on commit a6e3b26

Please sign in to comment.