News for hackers. Stuff that matters.
Re:How to make smaller C and C++ binaries by vodou on Sunday May 07, 2023 @05:48PM (#35855937)
This is pretty uncontroversial in an embedded system context. As others have said in this thread, nothing spectacular happens if STL throws, it just boils down to a std::terminate. You can mitigate this by being careful with what you do with STL.

Also, in a real-time system context, exceptions can be undesirable since they might cause non-deterministic behaviour.

Catching an exception can be surprisingly costly. Did some benchmarking a while ago on the embedded, real-time system I work on and saw that throwing and catching a std::runtime_error had about the same execution time as a rather slow CRC32 calculation (no pre-calculated tables, no special instructions) of a 256 bytes input array. (Of course, this depends a lot of the CPU architecture, compiler, etc.)

There are no comments on this comment yet.