Skip to content

Commit 062f327

Browse files
Feat: allow downcasting (useful for certain cases where uint32_t needs
to be cast to float16_t because the bits are stored in the lower half of the type)
1 parent 53b18b0 commit 062f327

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/intrinsic-test/src/x86/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub const PLATFORM_C_FORWARD_DECLARATIONS: &str = r#"
324324
template<typename T1, typename T2> T1 cast(T2 x) {
325325
if constexpr ((std::is_integral_v<T1> && std::is_integral_v<T2>) || (std::is_floating_point_v<T1> && std::is_floating_point_v<T2>)) {
326326
return x;
327-
} else if constexpr (sizeof(T1) == sizeof(T2)) {
327+
} else if constexpr (sizeof(T1) <= sizeof(T2)) {
328328
T1 ret{};
329329
std::memcpy(&ret, &x, sizeof(T1));
330330
return ret;

0 commit comments

Comments
 (0)