Claude_Sylvain

Compiler strange behavior with variable that use the "const" modifier.

Discussion created by Claude_Sylvain on Jul 11, 2007
Latest reply on Jul 11, 2007 by Claude_Sylvain
Hello,
 
I am using CodeWarrior V6.4 on Windows XP professionnal, on a project that use the MCF52223 MCU, and I have noticed a strange behavior of the compiler.
 
Below the explanation...
 
When defining an array like the following one:
 
/* +++ */
 
const unsigned char my_array[] = {0x01, 0x02, 0x03, 0x04, 0x05};
 
/* +++ */
 
This array is put in the .rodata section, and that's just what anybody expect.
 
But, when defining the save array with all value as 0x00, like the following:
 
/* +++ */
 
const unsigned char my_array[] = {0x00, 0x00, 0x00, 0x00, 0x00};
 
/* +++ */
 
The array is put in the .bss section !?!?
 
Why?
 
Is it a bug, or some strange feature that I do not understand ?
 
Claude.
Electro-Technica inc.
 
 
 

Outcomes