What trade-offs do exceptions have versus status- or expected-style error returns, especially at ABI, real-time, and latency-sensitive boundaries?
Show answer and explanation
Exceptions separate the success path from failure propagation and work naturally with RAII unwinding, but make non-local control flow possible and may be disabled or unacceptable where worst-case latency, binary constraints, or foreign ABIs dominate. Status or expected-style results make failure part of the type and avoid unwinding across a boundary, but callers must propagate or inspect them and result objects can add representation or branching costs. Neither strategy is universally faster: measure the actual error frequency, success path, toolchain, and target. Keep exceptions from crossing C or incompatible ABI boundaries, document the error contract, and translate to the boundary's chosen representation in one controlled layer.
Exceptions separate the success path from failure propagation and work naturally with RAII unwinding, but make non-local control flow possible and may be disabled or unacceptable where worst-case latency, binary constraints, or foreign ABIs dominate. Status or expected-style results make failure part of the type and avoid unwinding across a boundary, but callers must propagate or inspect them and result objects can add representation or branching costs. Neither strategy is universally faster: measure the actual error frequency, success path, toolchain, and target. Keep exceptions from crossing C or incompatible ABI boundaries, document the error contract, and translate to the boundary's chosen representation in one controlled layer.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.