feat(libc): implement std::_Throw_bad_optional_access #7872
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7872"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T11:53:31Z.
What
Implements
std::_Throw_bad_optional_access(_ZSt26_Throw_bad_optional_accessv, NIDKwzEip7m6TM) and thestd::bad_optional_accessexception class plumbing incore/libs/prx/libc/src/exception/StandardExceptions.cpp:bad_optional_accesstypeinfo, vtable, constructors (_ZNSt19bad_optional_accessC1Ev,C2Ev), destructors (D1Ev,D2Ev,D0Ev), andwhat()returning"bad_optional_access"(matching Dinkumware and libc++ conventions)._ZTISt19bad_optional_access_nid_postfixand_ZTSSt19bad_optional_access_nid_postfix.KwzEip7m6TMfor PPSA26578 (Unity/IL2CPP) and PPSA34015 (EA SPORTS FC 27).docs/dev/debt/libc.mdwith explicit note that the console libc.prx string is unverified.Tested
guest_bad_optional_accessunit test passes locally with CTest (100% tests passed out of 1).ExceptionRuntimecatch coverage tests throwing and catching byconst std::bad_optional_access&.python tools/check_conventions.py --base upstream/mainpasses 100%.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T11:54:19Z.
Progress report (
d047690→e775e45)📈 System libraries: 79.77% (+0.03%, +7 implemented functions)
✅ 7 implemented
_ZNKSt19bad_optional_access4whatEv_nid_postfix_ZNSt19bad_optional_accessC1Ev_nid_postfix_ZNSt19bad_optional_accessC2Ev_nid_postfix_ZNSt19bad_optional_accessD0Ev_nid_postfix_ZNSt19bad_optional_accessD1Ev_nid_postfix_ZNSt19bad_optional_accessD2Ev_nid_postfix_ZSt26_Throw_bad_optional_accessv_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T12:00:38Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libc.mdL100_ZNKSt19bad_optional_access4whatEv_nid_postfix_ZNSt19bad_optional_accessC1Ev_nid_postfix_ZNSt19bad_optional_accessC2Ev_nid_postfix_ZNSt19bad_optional_accessD0Ev_nid_postfix_ZNSt19bad_optional_accessD1Ev_nid_postfix_ZNSt19bad_optional_accessD2Ev_nid_postfix_ZSt26_Throw_bad_optional_accessv_nid_postfixcore/libs/tests/GuestBadOptionalAccess.cppdocs/dev/debt/libc.mdL100-101docs/dev/debt/libc.mdL100-101Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtcore/libs/tests/ExceptionRuntime.cppcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/exception/StandardExceptions.cppcore/libs/tests/GuestBadOptionalAccess.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtcore/libs/tests/ExceptionRuntime.cppcore/libs/prx/libc/CMakeLists.txtcore/libs/tests/ExceptionRuntime.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/prx/libc/CMakeLists.txtdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-19T12:25:28Z.
Review: COMMENTED
Verified the implementation and test in PR #7872:
_ZSt26_Throw_bad_optional_accessv_nid_postfixfollows the exact pattern of neighboring exceptions (_throw_bad_variant_access,_Throw_bad_weak_ptr), properly establishing type info and throwing viaThrowPlainwithwhat()returning"bad_optional_access".core/libs/tests/ExceptionRuntime.cppverifies that calling the export throws an exception caught asstd::bad_optional_accesswith the expectedwhat()string.docs/dev/debt/libc.mdupdated cleanly.The CI
conventionsworkflow is currently failing because the pull request description does not include the required template sections from.github/pull_request_template.md. Updating the PR body with### Testedand### Checklistwill clear this check:This implements
std::_Throw_bad_optional_accessfollowing the neighboringbad_variant_accessandbad_weak_ptrpattern:_ZTISt19bad_optional_access_nid_postfixand_ZTVSt19bad_optional_access_nid_postfixtype record and vtable deriving fromstd::exception._ZSt26_Throw_bad_optional_accessv_nid_postfix()throwing throughThrowPlain.what()returning"bad_optional_access", matching Dinkumware / libc++ conventions.ExceptionRuntime.cppverifying the exception is caught asstd::bad_optional_access.Fixes part of #7624.
Tested
Windows 11, MinGW-w64 GCC 15.2.0 (Release). Verified build and test in
ExceptionRuntime.cpp.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T12:57:26Z.
Heads-up: open PR #6079 already adds the same
_ZSt26_Throw_bad_optional_accessvexport (NIDKwzEip7m6TM) and exception type/vtable incore/libs/prx/libc/src/exception/StandardExceptions.cpp. This PR overlaps that implementation, although it adds a regression case for PPSA26578. Please coordinate with #6079’s author/maintainers on which implementation and tests should proceed; the two PRs currently also use differentwhat()strings, which would need a single verified choice.Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T13:44:16Z.
Thanks for the review and heads-up @MarcZX10!
Regarding the
what()string: on PR #6079, @adriadam10 requested changes specifically asking to use libc++'s"bad_optional_access"(matching the neighboringbad_variant_accessandbad_weak_ptrin AnyPS5) and to document under technical debt if unverified on hardware. This PR implements that exact libc++ string"bad_optional_access"and documents it indocs/dev/debt/libc.md.Also updated the PR description with the required
### Checklistand### Testedsections; all CI checks are now passing green. Happy to coordinate or adapt as maintainers prefer!Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T15:30:11Z.
Thanks for explaining the libc++ string choice and updating the PR description. One remaining accuracy point: the new technical-debt entry says
bad_optional_accessmatches Dinkumware/libc++ conventions, but it does not explicitly say the consolelibc.prxstring is unverified. The review on #6079 asked for that limitation to be recorded when title evidence is unavailable. Please add that clarification.The overlap with #6079 also remains: both PRs define
_ZSt26_Throw_bad_optional_accessv_nid_postfix, while #6079 additionally adds the exception type, constructors, destructor andwhat()exports. Please coordinate with its author or maintainers on one source of truth before either version merges.Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-19T15:51:02Z.
Thanks @MarcZX10!
Clarified technical debt: Updated
docs/dev/debt/libc.mdto explicitly record that the consolelibc.prxstring is unverified:Consolidated with #6079: Added the full exception type, constructors (
_ZNSt19bad_optional_accessC1Ev,C2Ev), destructors (D1Ev,D2Ev,D0Ev), andwhat()exports inStandardExceptions.cpp, along withGuestBadOptionalAccess.cppwhich validates the type record, vtable, construction, destruction, and pinswhat()to"bad_optional_access"(addressing the review feedback on #6079). This unblocks both PPSA26578 (#7624) and PPSA34015 (#6079), making this PR a single comprehensive implementation.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T18:21:52Z.
Thanks @ErenYeager1836. Merging this one: it carries the
std::bad_optional_accessexports and test from #6079 by @notaxeltv, plus the change @adriadam10 asked for there (what()returns"bad_optional_access", and the debt note says the PS5 string is unverified). Credit for the original implementation and test goes to @notaxeltv. Full CI is green one775e456d8(guest_bad_optional_accesspasses on Linux and Windows,exception_runtimeon Linux).