Skip to main content
sute
Associate III
October 11, 2023
Question

SBSFU Warray-bounds error when compiling data_init.c

  • October 11, 2023
  • 1 reply
  • 1999 views

We are updating our buildtools to GNU Tools for STM32 11.3.rel1 for a new project that is using an existing SBSFU 2.4.0 based bootloader from a previous project that was using an older compiler. Trying to compile the bootloader gives following errors:

 

 

 

data_init.c: In function 'LoopCopyDataInit': 
data_init.c:46:29: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds] 
 46 | dst[i] = src[i]; 
 | ~~~^~~ 
data_init.c:36:24: note: while referencing '_sidata' 
 36 | extern uint8_t _sidata asm("_sidata"); 
 | ^~~~~~~ 
data_init.c:46:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds] 
 46 | dst[i] = src[i]; 
 | ~~~^~~ 
data_init.c:82:24: note: while referencing '_sdata' 
 82 | extern uint8_t _sdata asm("_sdata"); 
 | ^~~~~~ 
data_init.c: In function 'LoopFillZerobss': 
data_init.c:63:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds] 
 63 | dst[i] = 0; 
 | ~~~^~~ 
data_init.c:56:24: note: while referencing '_sbss' 
 56 | extern uint8_t _sbss asm("_sbss"); 
 | ^~~~~ 
data_init.c: In function 'LoopCleanDataInit': 
data_init.c:89:20: error: array subscript 'uint32_t {aka volatile long unsigned int}[0]' is partly outside array bounds of 'uint8_t[1]' {aka 'unsigned char[1]'} [-Werror=array-bounds]
 89 | dst[i] = 0;
 | ~~~^~~
data_init.c:82:24: note: while referencing '_sdata'
 82 | extern uint8_t _sdata asm("_sdata");
 | ^~~~~~

 

 

 

I don't really understand what "partly outside array bounds" means and is this a false positive. Google doesn't really help. I am able to disable the errors with "#pragma GCC diagnostic" macros around the functions in data_init.c. Is it safe to ignore these errors? I would really prefer to avoid updating SBSFU version.

This topic has been closed for replies.

1 reply

Jocelyn RICARD
ST Employee
October 13, 2023

Hello @sute,

I could reproduce this compilation issue.

The problem comes from the type of the externals that is set as uint8_t instead of uint32_t.

Replacing in data_init.c, uint8_t by uint32_t in all extern references will solve the issue.

Best regards

Jocelyn

sute
suteAuthor
Associate III
October 13, 2023

Yes, this fixed the issue. Thanks! Still a bit confused about the warning though.