Why is AudioBuffer::setSize() noexcept?

The noexcept keyword seems to be wrong as the method throws a std::bad_alloc when the system runs out of memory (just learned it the hard way).

Is it required to be noexcept to support move semantics (I think it is called from constructors)? In this case we need another method (and change the API doc that comforts you with the warm safety of exception handling) that is allowed to throw on bad allocation since this is a common event when using big sample sets on 32bit systems.

oops - we’re normally very careful about the noexcept keyword, but that one does seem to be wrong, sorry! Will remove it…

Alright, thanks. You might want to remove it whenever you call allocateChannels, which means also every constructor as well as the = operator overload.

I wonder why the compiler didn’t warn about it. I believe GCC does it.

1 Like

Yeah, I always got a unreachable code warning in MSVC for my catch statement, but I kind of ignored it until now :slight_smile: