This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CARM compiler bug

A few days ago I encountered with strange program behavior, and the reason I found was compiler bug.
The problem can be revealed after compilation of the following code:

double Variance(int Sum, unsigned long long SquareSum, int NumSmp);
...
int ADC_GetSum(void);
...
{
...
    double tmp;
    int NumSmp
...
    tmp = Variance(ADC_GetSum(), ADC_GetSquareSum(), NumSmp);//!!
...
}


The line marked with //!! compiles incorrectly, i.e., the second parameters got corrupted before invoking Variance. Here is relevant lines from listing (*.LST) file produced by compiler:

   48:     tmp = Variance(ADC_GetSum(), ADC_GetSquareSum(), NumSmp);
 00000034  F7FF      BL          ADC_GetSum?T  ; T=0x0001  (1)
 00000036  FFE4      BL          ADC_GetSum?T  ; T=0x0001  (2)
 00000038  B401      PUSH        {R0}
 0000003A  A802      ADD         R0,R13,#0x8
 0000003C  6803      LDR         R3,[R0,#0x0] ; NumSmp
 0000003E  B408      PUSH        {R3}
 00000040  F7FF      BL          ADC_GetSquareSum?T  ; T=0x0001  (1)
 00000042  FFDE      BL          ADC_GetSquareSum?T  ; T=0x0001  (2)
 00000044  1C01      MOV         R1,R0  //!!
 00000046  1C0A      MOV         R2,R1  //!!
 00000048  BC08      POP         {R3}
 0000004A  BC01      POP         {R0}
 0000004C  F7FF      BL          Variance?T  ; T=0x0001  (1)
 0000004E  FFD8      BL          Variance?T  ; T=0x0001  (2)


One can see, that lines marked with //!! must be interchanged in order to correctly move content of R0..R1 to R1..R2.
I've spent half a day trying to find error in my program.
From the about window of IDE:

IDE-Version:
µVision3 V3.23
Tool Version Numbers:
C Compiler:         CA.Exe       V2.42
Assembler:          AA.Exe       V2.40b
Linker/Locator:     LA.Exe       V2.42


In this connection, I'm afraid to use this compiler any further. I would like to know, is there any document which describes CARM errors (I have not found one on this site). Or what can people with rich experience in embedded software development suggest to me in this situation?