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.

C6000-CGT: CGT 8.3.9 - cl6x: Not considering multiple exit conditions present in for loop syntax

Part Number: C6000-CGT

compiler upgraded from 7.3.23 -> 8.3.9 and facing stack corruption because compiler is not considering multiple exit conditions mentioned in the for loop.

FOR LOOP Syntax:
for(<iterator initialization>; <conditions (single/multipe)>; <iterator increment>)

Ex:

u8 a[constant_value] = {0};

for(u32 i=0; i < constant_value && i < f1(); i++)

{
  a[i] = 5; 
}

Old compiler 7.3.23 : considering both the exit conditions to come out of the loop [ i.e. taking MIN(constant_value, f1())] . It is behaving as expected and not causing any corruption issue.
New compiler 8.3.9 : considering only one condition i.e. i < f1() to exit the loop. This is leading to stack corruption due to for loop overrun.

Is there any optimization went in w.r.t to this area?

Please let me know is there any mechanism to resolve this issue with the new compiler 8.3.9. 

       

  

  • For one source file that contains a problem for loop, please follow the directions in the article How to Submit a Compiler Test Case.  If this file contains more than one for loop, then please add the comment /* PROBLEM FOR LOOP */ next to that loop.  When this for loop behaves incorrectly, how can you tell?  Exactly how do you see it?  What do you expect to see instead?

    Thanks and regards,

    -George

  • Thank you for submitting a test case through private messages.  I am not able to run the code.  But I do see compiler generated assembly code that I am confident has an error similar to the one you describe.  I filed the entry EXT_EP-10449 to have this investigated.  You are welcome to follow it with that link.

    Thanks and regards,

    -George