C++ no bad alloc exception for vector class
Hey guys,
I'm using C++ on my STM32F429 with G++ compiler.
I was trying to test the limits of the vector class. However I'm always running into a hard fault. I'm expecting a bad alloc exception instead.
http://www.cplusplus.com/reference/vector/vector/emplace_back/
states that:If a reallocation happens, the storage is allocated using the container's
http://www.cplusplus.com/vector::get_allocator
, which may throw exceptions on failure (for the defaulthttp://www.cplusplus.com/allocator
, bad_alloc is thrown if the allocation request does not succeed).vector<int> test_vector;
try { for (int i = 0; i < 50000; i++) { test_vector.emplace_back(i); if (0 == (i % 10)) { //alle 10 mal 1 ms pause osDelay(1); } } } catch (const exception& ex) {//Stop right here
configASSERT(0); }So where is my exception?
Exceptions are enabled in both the compiler and linker.
Compiler flags:
Invoking: MCU GCC Compiler
xxx\Debugarm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c11 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32F429xx -I'xxx/Giessomat/Inc' -I'xxx/Giessomat/Inc/User' -I'xxx/Giessomat/Inc/User/debug' -I'xxx/Giessomat/Inc/User/Testcases' -I'xxx/Giessomat/Inc/User/display' -I'xxx/Giessomat/Inc/User/display/img' -I'xxx/Giessomat/Inc/User/SD' -I'xxx/Giessomat/Inc/User/SD/XML' -I'xxx/Giessomat/Drivers/STM32F4xx_HAL_Driver/Inc' -I'xxx/Giessomat/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy' -I'xxx/Giessomat/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F' -I'xxx/Giessomat/Middlewares/ST/STM32_USB_Device_Library/Core/Inc' -I'xxx/Giessomat/Middlewares/ST/STemWin/Config' -I'xxx/Giessomat/Middlewares/ST/STemWin/inc' -I'xxx/Giessomat/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc' -I'xxx/Giessomat/Drivers/CMSIS/Device/ST/STM32F4xx/Include' -I'xxx/Giessomat/Middlewares/Third_Party/FatFs/src' -I'xxx/Giessomat/Middlewares/Third_Party/FreeRTOS/Source/include' -I'xxx/Giessomat/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS' -I'xxx/Giessomat/Drivers/CMSIS/Include' -Og -g3 -pedantic -Wall -Wextra -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF'Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.d' -MT'Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.o' -o 'Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.o' '../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c'Building file: ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.cLinker flags:
Building target: Giessomat.elf
Invoking: MCU G++ Linkerarm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -L'xxx/\Giessomat\Middlewares\ST\STemWin\Lib' -specs=nosys.specs -specs=nano.specs -u_printf_float -T'../STM32F429ZITx_FLASH.ld' -Wl,-Map=output.map -Wl,--gc-sections -fno-rtti -o 'Giessomat.elf' @'objects.list' -lSTemWin540_CM4_OS_GCC -lmFinished building target: Giessomat.elfWith these flags exceptions should be enabled right? So why am i not catching this exception?