3 ms·
> There is no cost to exceptions that are not thrown. This is not true for a variety of reasons, but the main ones are maybe missed optimizations and otherwise
by anonymoushn 4y ago
> There is no cost to exceptions that are not thrown.
This is not true for a variety of reasons, but the main ones are maybe missed optimizations and otherwise-unnecessary spills of objects into memory so that their destructors may be called.
> Also in C++ you have operators that are integrated in the type system and are resolved at compile-time to know whether an given expression can throw an exception or not.
Maybe if you only have a single TU or LTO? In general any function from another TU can throw an exception so you don't have this.
- mgaunard 4y ago> This is not true for a variety of reasons, but the main ones are maybe missed optimizations and otherwise-unnecessary spills of objects into memory so that their destructors may be called. The missed optimization opportunity you describe only affects the Windows ABI, designed in 1989. > Maybe if you only have a single TU or LTO? Whether a function can throw or not is part of its signature.