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.

compiler optimization problem!!

Genius 5910 points

Hello,

 I have the following problem.

 At optimization level 0 this works : (part of the intraspin Lab13C demo, clk.c)

*pMemory =  0x7010

numBytes  =  17

CLK_Handle CLK_init(void *pMemory,const size_t numBytes)
{
  CLK_Handle clkHandle;


  if(numBytes < sizeof(CLK_Obj))
    return((CLK_Handle)NULL);

  // assign the handle
  clkHandle = (CLK_Handle)pMemory;

  return(clkHandle);
} // end of CLK_init() function

At optimization level 2:  this is the result:

         CLK_init():
3e74b4:   1EA6        MOVL         @XAR6, ACC
791         return((CLK_Handle)NULL);
3e74b5:   0211        MOVB         ACC, #17
3e74b6:   0FA6        CMPL         ACC, @XAR6
3e74b7:   56C90003    BF           C$L1, LOS
3e74b9:   D400        MOVB         XAR4, #0x0
        C$L1:
3e74ba:   0006        LRETR       

I tried to make everything volatile. But that didn't work Again this is a copy of the intra-spin LAB 13C and did work.

This is a very recent problem.

edit: sizeof(CLK_Obj) = 17