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

Robert Seacord rcseacord at gmail.com
Tue Nov 27 15:33:40 GMT 2018


Clive,


In the following example:


typedef __packed struct

{

              uint16 a;

              uint8 b[ANNOYING_INCONVENIENT_LENGTH];

              uint16 c;

} tMyStruct;



tMyStruct buf;



Are you saying that 18.1 and 18.2 prohibit memcpy to &buf, ?


Thanks,

rCs

On Tue, Nov 27, 2018 at 8:16 AM Clive Pygott <clivepygott at gmail.com> wrote:

> What do you mean by a packed structure?  The term doesn't appear in the
> C17 standard or MISRA C:2012
>
> If you mean using a structure with no or known padding as the target of a
> block move or I/O, then that has to be done by a deviation as it breaks the
> rules on pointer arithmetic (18.1/18.2) that only allow pointer arithmetic
> within an array
>
>      Clive
>
> On Tue, Nov 27, 2018 at 12:05 PM Robert Seacord <rcseacord at gmail.com>
> wrote:
>
>> Is there any MISRA rules which disallow the use of packed structures?
>>
>> rCs
>> _______________________________________________
>> C-safe-secure-studygroup mailing list
>> C-safe-secure-studygroup at lists.trustable.io
>>
>> https://lists.trustable.io/cgi-bin/mailman/listinfo/c-safe-secure-studygroup
>>
> _______________________________________________
> C-safe-secure-studygroup mailing list
> C-safe-secure-studygroup at lists.trustable.io
>
> https://lists.trustable.io/cgi-bin/mailman/listinfo/c-safe-secure-studygroup
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.trustable.io/pipermail/c-safe-secure-studygroup/attachments/20181127/a9f36aea/attachment.html>


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