Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MISRA C Exemplar suite : Compilation errors
#1
I encountered a few cases in the exemplar suite(the list mentioned below) where in any standard compiler throws an error.
1. mc2_1101.c
2. mc2_1102.c
3. mc2_1903.c
4. mc2_1908.c
5. mc2_1914.c
6. mc2_1917.c

Are all the cases(but the ones which explicitly mention that the compiler is to fail) in the exemplar suite, in general, expected to
be successfully compiled by a "MISRA standard complaint" compiler?
<t></t>
Reply
#2
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:

  1. A syntax error;
  2. A violation of a language constraint;
  3. 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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)