MISRA Discussion Forums
Rule 2.1 deviation permit? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forum-4.html)
+--- Forum: MISRA C:2012 guidelines (https://forum.misra.org.uk/forum-21.html)
+---- Forum: 7.2 Compilation and build (https://forum.misra.org.uk/forum-179.html)
+---- Thread: Rule 2.1 deviation permit? (/thread-1287.html)

Rule 2.1 deviation permit? - dg1980 - 19-10-2016

Typically, on embedded systems with a simple RTOS, main is used as background task, so it never returns:

int main(void)
  for (;;)
  return 0;// Violates MISRA C 2012 2.1: unreachable code

Would this be a candidate for your deviation permits document?

Re: Rule 2.1 deviation permit? - misra-c - 09-12-2016

Thank you for your suggestion for a deviation permit.

RE: Rule 2.1 deviation permit? - misra-c - 04-05-2022

Technical Corrigendum 2 to MISRA C:2012 has added the following exception to rule 17.4.

Quote:For C99 and later, The Standard specifies that if control reaches the end of main without encountering a return statement, the effect is that of executing return 0. Therefore, for C99 and later, the return statement may be omitted for function main.
Omitting the return statement will remove the violation of rule 2.1