Files
AnyPS5/core/libs/tests/GuestThrowBadArrayNewLength.cpp
T
Eduardo Ruiz c7b70f44b0 feat(libc): implement std::_Throw(const std::bad_array_new_length&)
Follow the console libc.prx (PPSA02530) at 0xcb2d0: ignore the argument and throw the static bad_array_new_length object. Star Wars Racer (PPSA28416) imports it.
2026-10-29 01:03:00 +01:00

34 lines
1.2 KiB
C++

#include "prx/libc/include/Api.hpp"
#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstddef>
#include <cstdlib>
#include <cstring>
struct TypeRecord { const void* const* vtable; const char* name; const TypeRecord* base; };
struct Vtable { std::ptrdiff_t offset; const TypeRecord* type; const void* destroy; const void* deleteObject; const char* (APS5_VABI *what)(const LibcException::ExceptionObject*); };
extern "C" {
extern const TypeRecord _ZTISt9bad_alloc_nid_postfix;
extern const TypeRecord _ZTISt20bad_array_new_length_nid_postfix;
extern const Vtable _ZTVSt20bad_array_new_length_nid_postfix;
}
static void Require(bool value) { if (!value) std::abort(); }
int main() {
const auto& type = _ZTISt20bad_array_new_length_nid_postfix;
Require(std::strcmp(type.name, "St20bad_array_new_length") == 0);
Require(type.base == &_ZTISt9bad_alloc_nid_postfix);
const auto& table = _ZTVSt20bad_array_new_length_nid_postfix;
Require(table.offset == 0 && table.type == &type && table.what != nullptr);
bool thrown = false;
try {
_ZSt6_ThrowRKSt20bad_array_new_length_nid_postfix(nullptr);
} catch (...) {
thrown = true;
}
Require(thrown);
return 0;
}