aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-12-18 20:25:01 -0800
committerChris Robinson <[email protected]>2022-12-18 20:25:01 -0800
commit6753601b1570876ffa6ac36f8a5fde10c35a9a7c (patch)
tree9450c500cb8ef941742433cd1e4a4f4180bafccf /common
parentb4e281e2fb1cc15205cb8df7dd5ab7b91030b8c5 (diff)
Avoid unreachable() in assume_aligned
Another test to attempt to workaround MSVC build problems. Also, don't assume bit-wise value alignment for pointers as a default fallback.
Diffstat (limited to 'common')
-rw-r--r--common/opthelpers.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/common/opthelpers.h b/common/opthelpers.h
index 04c5f1d0..6b0c8db9 100644
--- a/common/opthelpers.h
+++ b/common/opthelpers.h
@@ -58,14 +58,16 @@ force_inline constexpr auto assume_aligned(T *ptr) noexcept
return std::assume_aligned<alignment,T>(ptr);
#elif HAS_BUILTIN(__builtin_assume_aligned)
return static_cast<T*>(__builtin_assume_aligned(ptr, alignment));
+#elif defined(_MSC_VER)
+ constexpr std::size_t alignment_mask{(1<<alignment) - 1};
+ if((reinterpret_cast<std::uintptr_t>(ptr)&alignment_mask) == 0)
+ return ptr;
+ __assume(0);
#elif defined(__ICC)
__assume_aligned(ptr, alignment);
return ptr;
#else
- constexpr std::size_t alignment_mask{(1<<alignment) - 1};
- if((reinterpret_cast<std::uintptr_t>(ptr)&alignment_mask) == 0)
- return ptr;
- unreachable();
+ return ptr;
#endif
}