Question Details

No question body available.

Tags

c language-lawyer misra cppcheck

Answers (1)

June 19, 2026 Score: 5 Rep: 59 Quality: Medium Completeness: 80%

pb->bar += 1u violates the same rule for the same reason (it also reads and writes a volatile), so it's not a workaround — it just isn't flagged by 13.3 because that rule's text only triggers on ++/--. The underlying concern is identical.

The intent of 13.3 is readability/reviewability: when ++ appears, a reviewer expects the increment to be the only thing happening, and a volatile access hidden inside it is easy to miss. On a non-volatile bar, pb->bar++ would be fully compliant.

  1. Split into an explicit read-modify-write through a local, making the volatile accesses visible: uint16_t tmp = pb->bar; tmp++; pb->bar = tmp; (and if your other concurrency handling involves disabling interrupts around this, that sequence is where the protection belongs anyway), or

  2. File a documented deviation. 13.3 is Advisory, so a deviation is legitimate per your project's MISRA compliance process if you've judged the construct acceptable.