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.

CCS/CCSTUDIO: Assertion fail is occurred with CCS10

Part Number: CCSTUDIO
Other Parts Discussed in Thread: 66AK2H12

Tool/software: Code Composer Studio

Hi 

When our customer run the program which I attached on this thread, the following fail message is asserted.

If they change the configuration for optimization to "not -O3" then the fail is not occurred.

Or if they compile the code on Visual Studio and not on CCS then the fail is not occurred.

Therefore, the fail may be caused from compiler.

- Device: 66AK2H12

- CCS #: CCS 10.1.1.00004  for Windows

For more information about the test, please refer to the attached test project.

compiler_test.zip

Thanks and Best regards,

HaTa.

  • Thank you for notifying us of this problem, and submitting a concise test case.  I can reproduce the same behavior.  I see the problem when compiling with --opt_level=1 or higher.  

    A bug report has not been filed, because the analysis is not far enough along to say where the investigation of the problem should focus.  I will file a bug report early next week, and let you know the ID number for it.

    Thanks and regards,

    -George

  • It turns out there is an error in your code.  Consider this code from func_fail ...

        else if(10 <= X && X < 10000){
            fxdLogX = -6 * (X - 5000) * (X - 5000) + 120040 * (X - 5000) - 1682360000;

    When X=10, the final value of the expression is -2430760200.  That number cannot be represented in a 32-bit signed integer.  The language standards say that overflow like that is undefined behavior.  A compiler may do anything in response to undefined behavior.  It may even compute the result you expect.  But, more often, the compiler assumes the undefined behavior never occurs.

    You need to change the code to account for this overflow.  One solution to consider is to change all the variables to type long long.

    Thanks and regards,

    -George

  • Hi George,

    Thank you so much!