diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-29 22:47:53 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-29 22:50:54 +0100 |
commit | cc5fab28af0a37aa48a6f445e1ac5cc5ef80f933 (patch) | |
tree | 67b76c0f5e9d50db38e293f086570dcfdc7d13dc /src/pcm | |
parent | a3f7127e7250196ce3cb7224739dffa2f10bf72e (diff) |
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
Diffstat (limited to 'src/pcm')
-rw-r--r-- | src/pcm/FloatConvert.hxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pcm/FloatConvert.hxx b/src/pcm/FloatConvert.hxx index 2270fbb90..70b00bcba 100644 --- a/src/pcm/FloatConvert.hxx +++ b/src/pcm/FloatConvert.hxx @@ -34,7 +34,7 @@ struct FloatToIntegerSampleConvert { typedef typename SrcTraits::long_type SL; 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"); gcc_const |