-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-9082
-
-
C6000_8.3.9
-
-
default
The attached test case contains this code ...
for (u32 i = 0; (i < arrSize && i < CByteAligner::bitsToOctetsRoundUp(tbSize)); i++) /* PROBLEM FOR LOOP */ localMem[i] = p_corruptedPdu[i];
The generated code accounts for the i < CByteAligner::bitsToOctetsRoundUp(tbSize)) part of the condition controlling the loop. But not the i < arrSize part.
Build it ...
% cl6x -@options.txt file.cpp
Inspect the compiler generated comments for the problem loop.
;* 128211 ----------------------- memset(&localMem, 0, 16u); ;* 128212 ----------------------- K$13 = tbSize+7u; ;* 128212 ----------------------- if ( !(C$5 = K$13>>3) ) goto g4; ;** ----------------------- U$21 = p_corruptedPdu; ;* 128213 ----------------------- L$1 = C$5; ;** ----------------------- U$23 = &localMem[0]; ;** ----------------------- #pragma MUST_ITERATE(1, 16, 1) ;** ----------------------- #pragma LOOP_FLAGS(4096u) ;** -----------------------g3: ;* 128213 ----------------------- *U$23++ = *U$21++; ;* 128212 ----------------------- if ( L$1 = L$1-1 ) goto g3; ;** -----------------------g4:
L$1 controls this loop. It down counts from CByteAligner::bitsToOctetsRoundUp(tbSize)) to 0. But this ignores the i < 16 part of the loop condition.