ScopedPointer bug?

There seems to be a bug in ScopedPointer::operator= from an rvalue.

To reproduce the bug one can change the JUCE Demo’s AudioLatencyDemo for example:

  • In AudioLatencyDemo::startTest(), remove the if (latencyTester == nullptr) check. It’s ok to create a new LatencyTester each time it seems.
  • Change the expression new LatencyTester (resultsBox) to ScopedPointer<LatencyTester> (new LatencyTester (resultsBox)).
  • Run the JUCE demo (tested here on OS X 10.11.6 with Xcode 8.0 beta 4, on the current develop branch - commit 70530a9) in debug.
  • In the audio latency demo, run the latency more than once. Every time after the first leaks the previous tester object.
  • Quit the JUCE demo. You should now get an assertion error for leaking LatencyTester objects.

This seems to be the offending line:

Cheers, Yair

Ah, good catch, thanks!

1 Like