pcm/FloatConvert: fix compile-time integer overflow for S32
The compile-time calculation for `factor` overflows because `1<<31` cannot be represented by `int`. By casting to `uintmax_t` first, we can avoid this overflow. Closes #380
This commit is contained in:
parent
a3f7127e72
commit
cc5fab28af
1
NEWS
1
NEWS
|
@ -1,6 +1,7 @@
|
||||||
ver 0.20.23 (not yet released)
|
ver 0.20.23 (not yet released)
|
||||||
* protocol
|
* protocol
|
||||||
- emit "player" idle event when restarting the current song
|
- emit "player" idle event when restarting the current song
|
||||||
|
* fix broken float to s32 conversion
|
||||||
* new clang crash bug workaround
|
* new clang crash bug workaround
|
||||||
|
|
||||||
ver 0.20.22 (2018/10/23)
|
ver 0.20.22 (2018/10/23)
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct FloatToIntegerSampleConvert {
|
||||||
typedef typename SrcTraits::long_type SL;
|
typedef typename SrcTraits::long_type SL;
|
||||||
typedef typename DstTraits::value_type DV;
|
typedef typename DstTraits::value_type DV;
|
||||||
|
|
||||||
static constexpr SV factor = 1 << (DstTraits::BITS - 1);
|
static constexpr SV factor = uintmax_t(1) << (DstTraits::BITS - 1);
|
||||||
static_assert(factor > 0, "Wrong factor");
|
static_assert(factor > 0, "Wrong factor");
|
||||||
|
|
||||||
gcc_const
|
gcc_const
|
||||||
|
|
Loading…
Reference in New Issue