From 7dd8fa993e5f1cdf1761d18bdf6f2376569baafa Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 30 Nov 2017 16:59:16 +0000 Subject: [PATCH] Fixes for templated code which could default-initialise a SIMDRegister object while expecting to get a zero-initialised value --- .../juce_audio_basics/buffers/juce_AudioSampleBuffer.h | 8 ++++---- modules/juce_core/maths/juce_MathsFunctions.h | 8 ++++---- modules/juce_dsp/frequency/juce_Windowing.cpp | 2 +- modules/juce_dsp/maths/juce_Polynomial.h | 4 ++-- modules/juce_dsp/native/juce_avx_SIMDNativeOps.h | 1 + 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index 41989e3e94..883666dc00 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -984,7 +984,7 @@ public: jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size); if (isClear) - return {}; + return { Type (0), Type (0) }; return FloatVectorOperations::findMinAndMax (channels[channel] + startSample, numSamples); } @@ -996,7 +996,7 @@ public: jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size); if (isClear) - return {}; + return Type (0); auto r = findMinMax (channel, startSample, numSamples); @@ -1006,7 +1006,7 @@ public: /** Finds the highest absolute sample value within a region on all channels. */ Type getMagnitude (int startSample, int numSamples) const noexcept { - Type mag = {}; + Type mag (0); if (! isClear) for (int i = 0; i < numChannels; ++i) @@ -1022,7 +1022,7 @@ public: jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size); if (numSamples <= 0 || channel < 0 || channel >= numChannels || isClear) - return {}; + return Type (0); auto* data = channels[channel] + startSample; double sum = 0.0; diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 77b8c41231..59e6d7a87a 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -135,7 +135,7 @@ template Type findMinimum (const Type* data, int numValues) { if (numValues <= 0) - return {}; + return Type (0); auto result = *data++; @@ -155,7 +155,7 @@ template Type findMaximum (const Type* values, int numValues) { if (numValues <= 0) - return {}; + return Type (0); auto result = *values++; @@ -176,8 +176,8 @@ void findMinAndMax (const Type* values, int numValues, Type& lowest, Type& highe { if (numValues <= 0) { - lowest = {}; - highest = {}; + lowest = Type (0); + highest = Type (0); } else { diff --git a/modules/juce_dsp/frequency/juce_Windowing.cpp b/modules/juce_dsp/frequency/juce_Windowing.cpp index 37cbc8dba0..79fbc7cd07 100644 --- a/modules/juce_dsp/frequency/juce_Windowing.cpp +++ b/modules/juce_dsp/frequency/juce_Windowing.cpp @@ -153,7 +153,7 @@ void WindowingFunction::fillWindowingTables (FloatType* samples, size // DC frequency amplitude must be one if (normalize) { - FloatType sum = {}; + FloatType sum (0); for (size_t i = 0; i < size; ++i) sum += samples[i]; diff --git a/modules/juce_dsp/maths/juce_Polynomial.h b/modules/juce_dsp/maths/juce_Polynomial.h index aa082e9fd4..c12ca32a11 100644 --- a/modules/juce_dsp/maths/juce_Polynomial.h +++ b/modules/juce_dsp/maths/juce_Polynomial.h @@ -90,7 +90,7 @@ public: FloatingType operator() (FloatingType x) const noexcept { // Horner's method - FloatingType y = 0; + FloatingType y (0); for (int i = coeffs.size(); --i >= 0;) y = (x * y) + coeffs.getUnchecked(i); @@ -144,7 +144,7 @@ public: for (int i = 0; i < N; ++i) { - FloatingType value = {}; + FloatingType value (0); for (int j = 0; j < Nmax; ++j) if (j >= 0 && j < N1 && i - j >= 0 && i - j < N2) diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h index db5decf191..694620a5fa 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h @@ -190,6 +190,7 @@ struct SIMDNativeOps static forcedinline __m256i JUCE_VECTOR_CALLTYPE equal (__m256i a, __m256i b) noexcept { return _mm256_cmpeq_epi8 (a, b); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE greaterThan (__m256i a, __m256i b) noexcept { return _mm256_cmpgt_epi8 (a, b); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE greaterThanOrEqual (__m256i a, __m256i b) noexcept { return bit_or (greaterThan (a, b), equal (a,b)); } + static forcedinline bool JUCE_VECTOR_CALLTYPE allEqual (__m256i a, __m256i b) noexcept { return _mm256_movemask_epi8 (equal (a, b)) == -1; } static forcedinline __m256i JUCE_VECTOR_CALLTYPE multiplyAdd (__m256i a, __m256i b, __m256i c) noexcept { return add (a, mul (b, c)); } static forcedinline __m256i JUCE_VECTOR_CALLTYPE notEqual (__m256i a, __m256i b) noexcept { return bit_not (equal (a, b)); }