Part Number: TMS320F2806
Tool/software: TI C/C++ Compiler
Hi,
I might be experiencing a bug with the current LTS compiler for the c2000 series. In essence, I'm doing something like the following.
In a file globals.c:
int foo = 1;
In a file bar.c
void bar(void){
printf("Foo is: %d\n", foo);
}
In a file baz.c
void baz(void){
printf("Foo is: %d\n", foo);
}
In a file main.c
void main(int){
bar();
baz();
for(;;){};
}
The printed result is something like "Foo is: 1\n Foo is: 0".
However, if I modify the print statement to: printf("Foo is: %d at %d\n", foo, (int32_t) &foo);, then the printed result is something like "Foo is: 1 at 12345\n Foo is: 1 at 12345".
Seemingly adding a print statement with the location of foo gives me the expected behavior.
I've debugged the code (as well as I can with the large level of compiler optimization that I've enabled) and foo is seemingly placed in a reasonable location in memory for both cases. As the application is moderately large it's hard for me to generate a minimum viable example, but I might be able to send the current code base under some conditions.
If anyone has any ideas as to how to progress from here I'd very much appreciate it!
Cheers,
Jonathan Lock