https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61664
--- Comment #3 from Alp Sayin <alpsayin at alpsayin dot com> --- (In reply to Alp Sayin from comment #2) > This issue still persists. I've hit the exact same problem with gcc-12.1.0 > built from zephyrproject-rtos/gcc fork. > But more interestingly, I noticed that following code example is able to > catch the exception. > Whereas any alteration either causes std:terminator to kick in or it causes > the unwinder to hang. > > int main() > { > try > { > throw 42; > } > // doesnt have to be char type can be any type, but remove this > catch and it exits (std::terminator goes to _exit()) > catch (char c){} > catch (int i) > { > printf("int catcher\n"); > std::exception_ptr p = std::current_exception(); > printf("Exception Value: 0x%08x/%dd\n", (int)&p, **(int**)&p); > printf("Exception Type: %s\n", p ? > p.__cxa_exception_type()->name() : > "null"); > return; > } > catch (...) > { > printf("all catcher\n"); > std::exception_ptr p = std::current_exception(); > printf("Exception Value: 0x%08x/%dd\n", (int)&p, **(int**)&p); > printf("Exception Type: %s\n", p ? > p.__cxa_exception_type()->name() : > "null"); > return; > } > printf("missed all catch"); > } Compiler flags as below: ``` microblazeel-zephyr-elf-g++ -gdwarf-4 /home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/bin/../lib/gcc/microblazeel-zephyr-elf/12.1.0/bs/m/mh/crtbegin.o zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj zephyr/CMakeFiles/zephyr_final.dir/dev_handles.c.obj zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj -o zephyr/zephyr.elf zephyr/CMakeFiles/offsets.dir/./arch/microblaze/core/offsets/offsets.c.obj -fuse-ld=bfd -Wl,-T zephyr/linker.cmd -Wl,-Map=/scratch/esnap_asayin/twister_out/qemu_microblaze/tests/subsys/cpp/libcxx/cpp.libcxx.newlib/zephyr/zephyr_final.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/microblaze/core/libarch__microblaze__core.a zephyr/lib/libc/newlib/liblib__libc__newlib.a zephyr/subsys/testsuite/ztest/libsubsys__testsuite__ztest.a zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/timer/libdrivers__timer.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a -L"/home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/bin/../lib/gcc/microblazeel-zephyr-elf/12.1.0/bs/m/mh" -L/scratch/esnap_asayin/twister_out/qemu_microblaze/tests/subsys/cpp/libcxx/cpp.libcxx.newlib/zephyr -lgcc -Wl,--print-memory-usage zephyr/arch/common/libisr_tables.a -no-pie -mlittle-endian -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -lstdc++ -Wl,--fatal-warnings -lm -Wl,-lc -L"/home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/microblazeel-zephyr-elf"/lib/bs/m/mh -Wl, -lgcc -lc /home/asayin/zephyr_sdks/microblaze_devel/zephyr-sdk-0.93.0-47-g4470827/microblazeel-zephyr-elf/bin/../lib/gcc/microblazeel-zephyr-elf/12.1.0/bs/m/mh/crtend.o ```