AnsweredAssumed Answered

ADuCM361 C compiler bug?

Question asked by dinrail on Jun 23, 2014
Latest reply on Jun 23, 2014 by dinrail

The following two sections of codes look the same to me, but it generates different result. Any explanation? Thanks for your time!

 

I  confirmed the result on Keil using ADuCM361

 

unsigned long mydata;   

int main(void)

{

short iTemp;   

long lTemp;   

unsigned long ulTemp;   

       

    mydata=0x04002123;

    iTemp=-1;

    mydata=mydata&0xFFFF0000+(unsigned short)iTemp;

//mydata=0x04002123!

 

    mydata=0x04002123;

    iTemp=-1;

    mydata=mydata&0xFFFF0000;

    ulTemp=(unsigned short)iTemp;

    mydata=mydata+ulTemp;

//mydata=0x0400FFFF

 

}

Outcomes