Skip to content

Commit 6fe0174

Browse files
committed
static_assert for 32-bit int
1 parent 419ac92 commit 6fe0174

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Source/astcenc_vecmathlib_none_4.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,10 @@ ASTCENC_SIMD_INLINE float float16_to_float(uint16_t a)
10561056
*/
10571057
ASTCENC_SIMD_INLINE vint4 float_as_int(vfloat4 a)
10581058
{
1059+
static_assert(sizeof(int) == sizeof(float), "int must be 32-bit");
1060+
10591061
vint4 r;
1060-
std::memcpy(r.m, a.m, 4 * 4);
1062+
std::memcpy(r.m, a.m, 4 * sizeof(int));
10611063
return r;
10621064
}
10631065

@@ -1071,7 +1073,7 @@ ASTCENC_SIMD_INLINE vint4 float_as_int(vfloat4 a)
10711073
ASTCENC_SIMD_INLINE vfloat4 int_as_float(vint4 a)
10721074
{
10731075
vfloat4 r;
1074-
std::memcpy(r.m, a.m, 4 * 4);
1076+
std::memcpy(r.m, a.m, 4 * sizeof(float));
10751077
return r;
10761078
}
10771079

0 commit comments

Comments
 (0)