[C-safe-secure-studygroup] MISRA and packed structures

Roberto Bagnara bagnara at cs.unipr.it
Tue Nov 27 14:33:27 GMT 2018


On 11/27/18 1:05 PM, Robert Seacord wrote:
> Is there any MISRA rules which disallow the use of packed structures?

Hi Robert.

As everything concerning the memory representation of structures
is implementation-defined, Directive 1.1 (Any implementation-defined
behaviour on which the output of the program depends shall be documented
and understood) applies.  In this respect, packed and non-packed
structures are no different from one another: any packing/non-packing
is just one of the way in which the compiler can define the behavior:

   6.7.2.1#14 Each non-bit-field member of a structure or union object
              is aligned in an implementation-defined manner appropriate
              to its type.

Here I am quoting C11 because I know that you care about that version
of the language, whereas for MISRA C:2012 I would have to quote the
equivalent sentences in C90 and C99.

In addition, to Directive 1.1, if the selection of a packed representation
is done with special syntax (as opposed to be controlled from the command
line), then advisory Rule 1.2 (Language extensions should not be used)
might apply.
Kind regards,

    Roberto

-- 
      Prof. Roberto Bagnara

Applied Formal Methods Laboratory - University of Parma, Italy
mailto:bagnara at cs.unipr.it
                               BUGSENG srl - http://bugseng.com
                               mailto:roberto.bagnara at bugseng.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2093 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.trustable.io/pipermail/c-safe-secure-studygroup/attachments/20181127/b67f269d/attachment.bin>


More information about the C-safe-secure-studygroup mailing list