简体   繁体   中英

MISRA C rule 12.2

I am new to MISRA rules concepts. I have a rule 12.2 warning saying

The value of an expression shall be the same under any order of evaluation that the standard permits (MISRA C 2004)

on the following C code:

PtToStack->Entry[PtToStack->top] = e ; 

where PtToStack is pointer to stack, Entry is array in the stack structure and top variable is a field of the stack structure. e has the same type of Entry .

Could any one help me to understand the warning?

This rule from MISRA-C:2004 (older standard) is concerning the order of evaluation of operands, in expressions where the order is not specified. There are plenty of examples and education material regarding the issue, below rule 12.2.

In your expression, there are no issues with unspecified order of evaluation. Therefore, the warning is incorrectly generated by your tool. Your static analyser is bad, file a bug report with the tool vendor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM