Red Error: Non terminating loop
조회 수: 6 (최근 30일)
이전 댓글 표시
Struct PIE_Reg {
union PIECTRL_REG PIECCTRL;//Size of each union is uint16
union PIECTRL_REG1 PIECCTRL1;//Size of each union is uint16
union PIECTRL_REG2 PIECCTRL2;//Size of each union is uint16
union PIECTRL_REG3 PIECCTRL3;//Size of each union is uint16
};
volatile struct PIE_Reg ASILBCheckPieCtrlChanges;
volatile struct PIE_Reg PieCtrlReg;
Func example(void){
uint8 index;
volatile uint16 *ASILBCheck = &ASILBCheckPieCtrlChanges.PIECCTRL.all;
volatile uint16 *piectrlpointer = &PieCtrlReg.PIECCTRL.all;
for(index = 0; index < 4; index++){
ASILBCheck[index] = piectrlpointer[index];
}
}
In function example at for loop I am getting the Red Error with following message:
The loop is infinite or contains runtime error
Loop fails due to a runtime error(maximum number of iterations:2)
Can you give me solution how to fix this and explain me what went wrong in the above code.
댓글 수: 0
답변 (1개)
John Boyd
2020년 1월 8일
You set your pointer to the address of a field, and when you go past the field it reports a pointer out of bounds. The solution is to either set the pointer to the struct base address (if possible) or use the "Enable pointer arithmetic across fields" option under Check Behavior in the Pointer section near the bottom of the panel. If you enable this setting it likely will result in more orange results elsewhere in the program, so I recommend using the base address in the code if that is possible.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Code Prover Analysis in Polyspace Platform User Interface에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!