Rule 5-2-7

Moderators: david ward, misra cpp

Post Reply
dg1980
Posts: 109
Joined: Wed Apr 27, 2016 2:33 pm
Company: Elektrobit Automotive GmbH

Rule 5-2-7

Post by dg1980 » Tue May 24, 2016 12:16 pm

Dear MISRA team,

IMHO, this rule is missing one important exception: casting to [unsigned]char* to access individual bytes is well defined in the standard (chapter 3.9 § 2)
In fact, you find this exception in MISRA C 2012 Rule 11.3.

misra cpp
Posts: 148
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 5-2-7

Post by misra cpp » Tue Oct 11, 2016 10:52 am

One of the differences between C and C++ is that all structs in C are PODs. The section you reference of the C++ standard only applies to POD structs. In general this operation is unspecified in C++. In the narrow case where the behaviour is well defined, it could be allowed by deviation.

A future version will remove the need for the deviation where this behaviour is well defined
Posted by and on behalf of
the MISRA C++ Working Group

Post Reply

Return to “6.5 Expressions (C++)”