Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC2012-Rule-8.17

In this section:
Synopsis

(Advisory) At most one explicit alignment specifier should appear in an object declaration.

Enabled by default

No

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Found multiple alignment specifications.

Coding standards
MISRA C:2012 Rule-8.17

(Advisory) At most one explicit alignment specifier should appear in an object declaration

Code examples

The following code example fails the check and will give a warning:

#include <stdint.h>
#include <stdalign.h>

alignas(16) alignas(8) int32_t c; /* Non-compliant - two alignment specifiers */

The following code example passes the check and will not give a warning about this issue:

#include <stdint.h>
#include <stdalign.h>

int32_t a; /* Compliant - no alignment specifier */
alignas(16) int32_t b; /* Compliant - one alignment specifier */