cancel
Showing results for 
Search instead for 
Did you mean: 

Exceptions can't be catched, program abruptly terminates instead.

XR.1
Senior

Hi,

Exceptions allowed, the program abruptly terminates:

Captura de pantalla de 2025-09-29 21-19-01.png

The program reaches this point before it terminates:

Captura de pantalla de 2025-09-29 21-21-52.png

The debugger is set (I guess) no to halt on exceptions:

Captura de pantalla de 2025-09-29 21-25-21.png

 

Any hints? Did I forget to initialize something?

 

 

4 REPLIES 4
Aimen1
ST Employee

Hello,

Could you please share the STM32CubeIDE and GCC versions that you are using?

Also, is it possible to send us your example?

Thanks.

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
fenardC
Associate

Hi

What is working for me, is to select the correct the Runtime Library in the STM32CubeIDE for your project, in my case with v1.18.1, nano_c_standard_cpp

You can have a look in my public github repository (https://github.com/fenardC/B-U585I-IOT2A_EMW) with project in C/C++ on STM32.
This example uses C++ exceptions and i hope it will help you. 

Regards.


C.Fenard

Hi!

From a project compilation I got this:

 

GNU C++17 (GNU Tools for STM32 10.3-2021.10.20211105-1100) version 10.3.1 20210824 (release) (arm-none-eabi)
compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

 

The project is a very simple one. I was testing some C++20 features and specially exceptions for embedded systems, 'cause I want to write a blog post on this matter, but first I need to be sure that exceptions work altogether!

 

 

 

Hi!

Thank you for the advice, it worked!.

I've been thinking that exceptions for embedded systems weren't that bad... until I made them work.

In fact the nano_c_stardad_cpp variant let the exceptions to run as expected, with a high price to pay, though: massive FLASH usage:

Captura de pantalla de 2025-10-02 00-53-15.png

No exceptions at all: 6KB

nano_c_reduced_cpp: 12 KB and doesn't work

nano_c_standard_cpp: 52KB (OMG!)

 

For chips with plenty of memory that can be feasible, but not for small size uC.

 

Such figures are correct?