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 doesn't generate call to a function within LISTING file

Hello Support,

In the attached Compiler_Bug.zip file, use UNZIP using Folder option to a directory.

Once you run the compile.bat file from that directory,

assuming compiler path for your PC is correct in compile.bat file, you will see ramchk.lst file within OUT sub-folder.

In the ramchk.c file, there is a call to Empty_Function() at line 219.

I don't see the corresponding "BL   Empty_Function" statement within ramchk.lst.

Please help me understand this issue.

Thank you.

Regards

Pashan

 

Compiler_Bug.zip
  • Here is line 206 ...

     if( (TRUE == Get_Ram_Sec_Error()) && ((Get_Ram_Ecc_Sec_Address() * 8) == (unsigned32_T)ECC_TEST_VAR_OFFSET ) )

    This if controls the block which contains the call to Empty_Function.  It turns out Get_Ram_Sec_Error is a macro which is really just a read of a bit field.  I can tell that the the compiler thinks the Get_Ram_Sec_Error bit field is not set.  I don't know how it knows that.  Can you verify whether this assumption is correct or not?  Because this if test is false, the entire block it controls is removed.

    Thanks and regards,

    -George

  • George,

    Get_Ram_Sec_Error() will be set in the Interrupt if the Interrupt occurs.

    I am unable to understand how Compiler will assume that BIT to be always FALSE.

    It's a part of bit_field of a RAM Variable.

    Why Compiler will assume it as a CONSTANT FALSE?

    Thank you.

    Regards

    Pashan

     

  • The compiler knows the bit will always be false because the test is nested inside an if statement which tests the opposite condition.  That is, you have code which looks like this:

       if(FALSE == Get_Ram_Sec_Error())
       {
          [..]
          if( (TRUE == Get_Ram_Sec_Error()) && [...] )
          {
    

    If you expect an interrupt to update Run_Time_Mem_Test_Result, you must declare it volatile.

  • Is that variable declared "volatile"?  That's essential, if a variable is modified in a way that is not visible to the compiler.

    See, for example, http://www.cognitus.net/html/tutorial/usingVolatile.html .