1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 17:31:47 +02:00

Make panic() and unreachable() robust

Plus one or two tweaks.
This commit is contained in:
Robert Hensing 2024-07-24 17:53:17 +02:00
parent 3172e88af5
commit 55a654abfd
2 changed files with 27 additions and 9 deletions

View file

@ -275,17 +275,13 @@ void throwExceptionSelfCheck();
/**
* Print a message and abort().
*
* @note: This assumes that the logger is operational
*/
[[noreturn]]
void panic(std::string_view msg);
/**
* Print a basic error message with source position and abort().
* Use the unreachable macro to call this.
*
* @note: This assumes that the logger is operational
* Use the unreachable() macro to call this.
*/
[[noreturn]]
void panic(const char * file, int line, const char * func);
@ -295,6 +291,6 @@ void panic(const char * file, int line, const char * func);
*
* @note: This assumes that the logger is operational
*/
#define unreachable() (panic(__FILE__, __LINE__, __func__))
#define unreachable() (::nix::panic(__FILE__, __LINE__, __func__))
}