buffer.getSample() error in Release mode?

Hi there! Having an issue with buffer.getSample() in release mode, but not in debug mode. I’ve allocated a buffer in prepareToPlay with buffer.setSize(numChannels, numSamples) and verified using std::cerr that the buffer has 2 channels and 2205 samples.
In my process block, I have a function that takes a reference to said buffer. The function has this code:

auto numChannels = buffer.getNumChannels();
auto numSamples = buffer.getNumSamples();
for (int c = 0; c < numChannels; ++c)
    for (int i = 0; i < numSamples; ++i)
        std::cerr << "c = " << c << ", i = " << i << "\n";
        std::cerr << "sample = " << buffer.getSample(c, i) << "\n";
// ...

The console shows that when c = 0 and i = 0, there is an error with buffer.getSample(c, i). I’ve redefined getSample as follows:

Type getSample (int channel, int sampleIndex) const noexcept
    std::cerr << "getting sample\n";
    std::cerr << "numChannels = " << numChannels << "\n";
    std::cerr << "channel = " << channel << "\n";
    std::cerr << "size = " << size << "\n";
    std::cerr << "sampleIndex = " << sampleIndex << "\n";
    jassert (isPositiveAndBelow (channel, numChannels));
    jassert (isPositiveAndBelow (sampleIndex, size));
    return *(channels[channel] + sampleIndex);

My console output is

getting sample
numChannels = 2
channel = 0
size = 2205
sampleIndex = 0

And then the plugin crashes, with a bad access violation. It’s clear from my debug statements that I’m not trying to access anything outside the channels array. Any ideas what this might be? Could it be a problem with buffer allocation in JUCE? Or perhaps the reference? (which would be weird - I’ve never had a problem before with passing a buffer reference to a function) I have “Relax IEEE Compliance” disabled in the Projucer, and -O3 optimization. I’m on the latest version of JUCE. Thanks!

Ah, I figured it out! I am using a different computer with a different version of Xcode than I normally build on, and I eventually saw the warning that on Xcode 15 the new linker can produce a broken binary. Disabling link-time optimization fixed the problem, and so did downgrading to Xcode 14.3.