5 ms·
Mostly it works, except for memory allocation failures. These will terminate the process. But then, the Itanium C++ ABI has some quirks that make it impossible
by fweimer 4y ago
Mostly it works, except for memory allocation failures. These will terminate the process. But then, the Itanium C++ ABI has some quirks that make it impossible to throw an exception (any exception) in all out-of-memory conditions, so perhaps that's okay. (Throwing an exception must allocate, and the ABI currently does not allow to throw a pre-canned std::bad_alloc on allocation failure instead.)
- bregma 4y agoNot only does the Itanium C++ ABI allow for using a pre-canned std::bad_alloc (because __cxa_allocate_exception() can do whatever it wants on an allocation failure), but most of the common implementations do just that.
- fweimer 4y agoI meant that the interface for __cxa_allocate_exception is designed in such a way that it cannot substitute std::bad_alloc for the exception being allocated.
- MrQuincle 4y agoHow's that implemented? I'm just used to embedded. Implementing sbrk etc. Some flags i use to disable exceptions # The default flags will be used in all build types # The C/C++ shared flags are in DEFAULT_C_AND_CXX_FLAGS, the ones particular for C or C++ in DEFAULT_X_FLAGS # The flags mean the following: # * no-exceptions disable exceptions support and use C++ libs without exceptions # * delete-dead-exceptions throw away instructions which only purpose is to throw exceptions # * no-unwind-tables stack-walking code for backtrace generation (TODO: we might want to enable this in Debug!) # * no-non-call-exceptions do not convert trapping instructions (SIGSEGV, etc) into exceptions # * thumb use Thumb mode (optimized instruction set) # * function-sections put every function in its own segment, now it can be garbage collected # * data-sections put every variable in its own segment # * no-strict-aliasing allow *int = *float aberrations # * no-builtin do not use abs, strcpy, and other built-in functions # * short-enums use a single byte for an enum if possible SET(DEFAULT_CXX_FLAGS "-std=c++17 -fno-exceptions -fdelete-dead-exceptions -fno-unwind-tables -fno-non-call-exceptions")
- fweimer 4y ago-fno-exceptions should be sufficient for this, especially if you link statically. People also use `-fno-rtti` to save the extra data by dynamic_cast etc.