Position of "ascii" provokes an error in GCC

After hours debuging an inexplicable error, I finally found the inexplicable solution :bulb: .

Code #1

void HexToCoord (bool LatLon1, s32 Coord1, ascii * pRetCoord)
{
	
	ascii buffer1[15]; // ascii located here generates the error.
	ascii pSignal[3];
	s32 Deg1=0;
	s32 Min1=0;
	s32 MMM1;
						 
	// Mycode

	// First occurrence of "buffer1"
	wm_sprintf(buffer1,"%02lu", Min1);
           
    // Rest of the code

}

Debug mode: works fine!
Compiled in GCC: Generates the error:

“Error: byte or halfword not valid for base register – strb r3,[sp]' byte or halfword not valid for base register --strb r3,[sp,#1]’”

After changing the position of the first “ascii” to:

Code #2

...
	ascii pSignal[3];
	s32 Deg1=0;
	s32 Min1=0;
	s32 MMM1;
   ascii buffer1[15]; // New location

...

Debug mode: works fine!
Compiled in GCC: works fine!

It is really a strange behavior.

hmm, strange…

Sounds like a bug in the GCC compiler…

Did you ever try another compiler, maybe the ARM?
Did you also try to change the buffer size? To for example 16?

Just curious…

/Snoooze

i experienced something similar, just when you declare two char arrays one after one the second on emulator it is pointed at the same position of first, just initialize thechar arrasy to a null string, and you have no more problems, just try the first code with initialize .

ascii buffer1[15]="\0";
ascii pSignal[3]="\0";

we always should initialize vars :wink: