Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

Strange memory issue with sscanf

$
0
0

Using gcc-arm-none-eabi-5_42016q3-20160926 tool chain in eclipse.Processor: STM32F030I have a 3 line program that starts before any hardware initializations to isolate the problem:

    int a;    char * num="3";    memset(0x20000970,0XAA, 0x20001f00-0x20000970);    sscanf(num, "%i",&a);

I have set the RAM to 0XAA so I can see what gets clobbered, leaving plenty of room for the stack.After the memset instruction the stack pointer is at 0X20001F78, the memory is 0XAA up to 0X20001F00 as expected. After I execute the sscanf function the stack pointer is back at 0X20001F78 however memory was clobbered all the way down to 0X20001BB4 which makes me think that either this simple call took almost 1K of stack or there is some other error in the routine. I have stopped using this function but am curious whether this is expected behavior? Also, is there a list of C functions that one should avoid in embedded systems, this was a surprise to me but from searching I see I am not alone.


Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>