Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Rule-8.15

In this section:
Synopsis

(Required) All declarations of an object with an explicit alignment specification shall specify the same alignment.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Found different explicit alignment specification.

This is a link analysis check.

Coding standards
MISRA C:2012 Rule-8.15

(Required) All declarations of an object with an explicit alignment specification shall specify the same alignment

Code examples

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

#include "example.h"

/* example.h
#include <stdint.h>
#include <stdalign.h>
*/
extern alignas (8) int32_t x; /* Non-compliant - not consistently explicit */
alignas (16) int32_t y; /* Compliant */

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

#include "example.h"

/* example.h
#include <stdint.h>
#include <stdalign.h>
*/

alignas (16) int32_t x; /* Non-compliant - not consistently explicit */
alignas (16) int32_t y; /* Compliant */