This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ARM Compiler code-generation bug

I don't have time to produce an isolated example case right now (I can later this week), but I hope it's obvious enough that someone might be able to figure out what's going on.

I have the following serial port code:

int16_t SerialPort::getByte(uint32_t timeout)

{

  char rxChar;

  if(rxQueue.receive(&rxChar, timeout / 1000))

  {

    receivedBytes++;

    return (int16_t)rxChar;

  }

  else

    return -1; 

}

This produces the following assembly (error in bold):
E92D500F STMFD           R13!, {R0, R1, R2, R3, R12, R14}
EEF1CA10 FMXR            R12, FPSCR
E92D1000 STMFD           R13!, {R12}
E58D1004 STR             R1, [R13, #4]
E58D0000 STR             R0, [R13]
E59D0004 LDR             R0, [R13, #4]
E3A01FFA MOV             R1, #1000
EB0010B8 BL              __aeabi_uidivmod
E59DC000 LDR             R12, [R13]
E1A02000 MOV             R2, R0
E28D1008 ADD             R1, R13, #8
E28C000C ADD             R0, R12, #12
EB001284 BL              receive
E3500000 CMP             R0, #0
0A000004 BEQ             $C$L15
E59DC000 LDR             R12, [R13]
E59C0024 LDR             R0, [R12, #36]
E2800001 ADD             R0, R0, #1
E58C0024 STR             R0, [R12, #36]
EA000001 B               $C$L16
            $C$L15:
E3A0C0FF MOV             R12, #255
E5CDC008 STRB            R12, [R13, #8]
            $C$L16:
E5DD0008 LDRB            R0, [R13, #8]
E58D0000 STR             R0, [R13]
E8BD1000 LDMFD           R13!, {R12}
E8BD900F LDMFD           R13!, {R0, R1, R2, R3, R12, PC}
The notable error here is that the function prolog and epilog save and restore r0, which according to ABI is the return value.  Before r0 is popped from the stack, it contains the return value I'd expect; afterwards it contains the first function argument, which is the value it held when it entered the function.
The serial port file is compiled with the following flags:
cl470 -mv7R4 -g <includes> --diag_warning=225 --enum_type=packed --elf --abi=eabi --code_state=32 --float_support=VFPv3D16 --preproc_with_compile --preproc_dependency="serial_port.pp" --obj_directory="<objs>"  "serial_port.cpp"
I'm using CCS 4.2.4.00033 on Windows XP, developing for the TMS570 architecture.
This is blocking development for me at the moment, and the severity of this error is obvious.
Thanks,
Tom