05-11-2012, 10:56 AM
No, it's not necessarily the case that the exemplar suite will compile without producing diagnostics (errors, warnings, etc). Examples that are marked as non-compliant may result in diagnostics if the corresponding code gives rise to:
Any conforming implementation ("standard compiler") is required to produce a diagnostic in cases (1) and (2). So, it is expected that compiling mc2_1908.c would produce a diagnostic because calling a macro with the wrong number of arguments violates a language constraint. Similarly, compiling mc2_1917.c would produce a diagnostic because the syntax of conditional code blocks requires them to be terminated within the same source file. The rules in question are in some sense unnecessary because a conforming implementation is required to produce a diagnostic. They are present because some (non-conforming) compilers have been reported as not producing a diagnostic.
All the other diagnostic messages are being produced because the behaviour of the non-compliant example is undefined. A compiler may produce a diagnostic or it may quietly compile the code, possibly with the expected results and possibly with some quite unexpected results. A MISRA C checker would be expected to produce a diagnostic for all non-compliant examples.
Note: there is no concept of a "MISRA standard compliant compiler" in the MISRA C Guidelines, only of a "conforming implementation", i.e. one that satisfies the requirements of the ISO C Standard (C90).
- A syntax error;
- A violation of a language constraint;
- Undefined behaviour.
Any conforming implementation ("standard compiler") is required to produce a diagnostic in cases (1) and (2). So, it is expected that compiling mc2_1908.c would produce a diagnostic because calling a macro with the wrong number of arguments violates a language constraint. Similarly, compiling mc2_1917.c would produce a diagnostic because the syntax of conditional code blocks requires them to be terminated within the same source file. The rules in question are in some sense unnecessary because a conforming implementation is required to produce a diagnostic. They are present because some (non-conforming) compilers have been reported as not producing a diagnostic.
All the other diagnostic messages are being produced because the behaviour of the non-compliant example is undefined. A compiler may produce a diagnostic or it may quietly compile the code, possibly with the expected results and possibly with some quite unexpected results. A MISRA C checker would be expected to produce a diagnostic for all non-compliant examples.
Note: there is no concept of a "MISRA standard compliant compiler" in the MISRA C Guidelines, only of a "conforming implementation", i.e. one that satisfies the requirements of the ISO C Standard (C90).
Posted by and on behalf of the MISRA C Working Group