^

MISRA C:2012 Amendment 4

By Andrew Banks - Technical Specialist
30th March 2023
  • Blog
  • MISRA C:2012 Amendment 4

Andrew Banks, Chairman of the MISRA C Working Group, brings news from Nuremburg, Germany:

The Announcement

At the 2023 edition of the Embedded World Conference, MISRA announced the publication of MISRA C:2012 Amendment 4, Updates for ISO/IEC 9899:2011/2018 Phase 3 — Multi-threading and atomics.

This concludes the planned enhancements for C11/C18.

What’s New?

Overview

At 52 pages, MISRA C:2012 Amendment 4 is quite a publication in its own right, and it builds upon the previous enhancements to MISRA C:2012. It adds 22 new guidelines and revises a further 17 existing guidelines.

Atomics

C11 introduced the stdatomic.h header file, providing support for atomic objects.

MISRA C:2012 Amendment 4 adds four new Rules (R.9.7, R.11.10, R.12.6 and R.21.25) and includes minor changes to a further four existing Rules (R.9.1, R.11.3, R.11.8 and R.18.6).

Of these, most should be uncontroversial although the new rule R.21.25, which requires that all memory synchronization operations shall be executed in sequentially consistent order, will require a deviation should anyone desire to use any other supported method.

Multi-threading

C11 introduced the threads.h header file, providing support for concurrency and multi-threading.

MISRA C:2012 Amendment 4 adds three new Directives (D.5.1, D.5.2 and D.5.3) and eleven new Rules (R.21.26 plus R.22.11 though to R.22.20) and modifies R.13.2 to extend the consideration of persistent side effects due to thread interleaving.

Again, these changes should be uncontroversial.

Other Changes

In addition to these C11/C18 changes, a number of other changes have been introduced by MISRA C:2012 Amendment 4:

  • Small integer constants: building on Rule R.7.5 which was added in Amendment 3, new Rule R.7.6 restricts the use of the small integer constant macros, as these do not typically expand correctly.
  • Unused Objects: new Rule R.2.8 advises that all declared objects to be used.
  • Designated Initializers: an amendment to Rule R.9.4 clarifies the guidance on the use of designated initializers.
  • Chained Initializers: new required Rule 9.6 requires that, if an aggregate initializer uses designators to specify elements, and any designator in the initializer is chained, every initializer in the entire containing initializer list shall specify an element explicitly using a designator. This reduces the likelihood of unintentionally overwriting initialized values.
  • Variable Length Arrays: a revision to Rule R.18.8 and new Rule R.18.10 provide more focussed restrictions on the use of variable length arrays.
  • Hyperlinks in Comments: an Exception to Rule R.3.1 permits the use of URIs in comments – the existing wording means that the // of a URI (eg https://misra.org.uk) was unintentionally determined to be a C++ comment marker.

A small number of minor/editorial changes complete the document.

What about MISRA C:2023?

In addition to the announcement of the publication of MISRA C:2012 Amendment 4, Embedded World 2023 conference delegates also heard that a new consolidated version of MISRA C would be published in April 2023. The release date has been timed to mark the 25th anniversary of the first edition of MISRA C.

Keynote presentation to delegates in the MISRA track. Embedded World conference 2023.

This new document will be called MISRA C:2023, and will consolidate Amendment 2 (February 2020), Technical Corrigendum 2 (March 2022), Amendment 3 (October 2022) and Amendment 4 (March 2023).

Those documents are placed into the context of a timeline on this page.

What Next for MISRA C?

The MISRA C Working Group will be meeting in March 2023 to determine the roadmap for the future. Items for consideration will include:

  • ISO/IEC 9899:202x: the new edition of the C Standard is scheduled for publication towards the end of 2023 (or maybe into 2024) – there will undoubtedly be things that the MISRA C Working Group doesn’t like!  Note: MISRA C has full liaison with ISO/IEC JTC1/SC22/WG14.
  • ISO/IEC 24772: the MISRA C Working Group has already commenced a review of this document, which provides guidance to avoiding vulnerabilities in programming languages, to ensure that all identified weaknesses are addressed by MISRA C.
  • The Common Weakness Enumeration: the MISRA C Working Group has already commenced a review of the CWE, given the growing prominence of security vulnerabilities.

Acknowledgements

The MISRA Logo

The MISRA Consortium

MISRA, MISRA C and the triangle logo are registered trademarks owned by The MISRA Consortium Limited.

Other product or brand names are trademarks or registered trademarks of their respective holders.

About the Author
Andrew Banks

Andrew Banks is a Technical Specialist at LDRA with more than 30 years’ experience of high-integrity real-time/embedded software development.

A Chartered Fellow of the British Computer Society, he graduated from the University of Lancaster in 1989, and has spent most of his career within the aerospace, defence and automotive sectors.

Andrew is committed to standards development – he has been involved with MISRA since 2007 and has been Chairman of the MISRA C Working Group since early 2013; he is the Chairman of the BSI “Software Testing” Working Group; and an active participant in other BSI, ISO, IET and SCSC work, including the 2nd Edition of ISO 26262.

FREE 30 Day
TRIAL

Email Us

Email: info@ldra.com

Call Us

EMEA: +44 (0)151 649 9300

USA: +1 (855) 855 5372

INDIA: +91 80 4080 8707

Connect with LDRA