5.4.5: AudioBlock<SIMDRegister<float>>::clear() no longer works

Hi there,

the recent AudioBlock refactoring broke the clear() method, if the SampleType is a SIMD type.
The following code won’t work:

AudioBlock<SIMDRegister<float>> ab;
ab.clear();

No matching function for call to 'clear' <- FloatVectorOperations.

The clearInternal() method, which is used to clear the data, is no longer reinterpret_casting the SampleType to float in order to use the FloatVectorOperations.

Am I supposed to use clear differently? Or did it just slip through testing? :slight_smile:
Maybe something for @tpoole?

Seems like adding reinterpret_cast<NumericType*> to the clearInternal() method should do the trick:

In juce_AudioBlock.h line 578:

    void JUCE_VECTOR_CALLTYPE clearInternal() const noexcept
    {
        auto n = static_cast<int> (numSamples * sizeFactor);

        for (size_t ch = 0; ch < numChannels; ++ch)
            FloatVectorOperations::clear (reinterpret_cast<NumericType*> (getChannelPointer (ch)), n);
    }

All the other methods using FloatVectorOperations are also affected (see fillInternal()), so the reinterpret_cast has to be added to those as well. Unless it will put directly to getChannelPointer as it was before, however that would break the interface, as it wouldn’t return SampleType* anymore.

That was an oversight. Fixed here:

Thank you for reporting!

Thanks for fixing! Would you mind cherry-picking it to master?

I’d like it to have a few days on develop first, but have no objections to moving it over if no other problems are reported.

I really dislike the concept that master can change after release, how are we supposed to know what’s a master and what’s an updated master without monitoring the forum?

Easy just subscribe to this in an RSS
https://github.com/WeAreROLI/JUCE/commits/master.atom

You can see all commits to develop the same way
https://github.com/WeAreROLI/JUCE/commits/develop.atom

There are also release-tags, so if you want to stick with the release-versions you can always pull the tags, if you want to get the latest master-worthy changes you can pull from master, and if you want to use the most recent develop changes -> develop :slight_smile:

1 Like