Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-5-0-9

In this section:
Synopsis

(Required) An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

One or more explicit integral conversions were found that change the signedness of the underlying type of a cvalue expression.

Coding standards

This check does not correspond to any coding standard rules.

Code examples

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

#include <stdint.h>
void f ( )
{
  int8_t s8;
  uint8_t u8;
  s8 = static_cast< int8_t >( u8 + u8 ); // Non-compliant
}

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

#include <stdint.h>
void f ( )
{
  int8_t s8;
  uint8_t u8;
  s8 = static_cast< int8_t >( u8 )
     + static_cast< int8_t >( u8 ); // Compliant
}