kvn
kvn

Reputation: 1323

What does __throw_bad_alloc() do?

I came across this using the static analyzer in Xcode and couldn't find any documentation describing exactly what this function does. I've dome some Google searching without much luck. I've only found references to this function in some open source projects.

Upvotes: 2

Views: 1388

Answers (1)

Toby Speight
Toby Speight

Reputation: 30873

It's an internal artefact of the implementation, that you as a user don't need to know about.

We know it's internal, as it uses a reserved identifier (names containing consecutive underscores are all reserved), and we might guess from the name that it probably just throws a std::bad_alloc exception.

It may be more complex than simply throwing an exception in the normal way, as it has to function without making any allocations of its own. It may also have configurable behaviour for use in non-default environments (e.g. where exceptions are disabled).

Upvotes: 1

Related Questions