Main Content

AUTOSAR C++14 Rule M5-0-6

An implicit integral or floating-point conversion shall not reduce the size of the underlying type

Description

Rule Definition

An implicit integral or floating-point conversion shall not reduce the size of the underlying type.

Rationale

A conversion that reduces the size of the underlying type can result in loss of information.

Polyspace Implementation

If the conversion is to a narrower integer with a different sign, then rule M5-0-4 takes precedence over rule M5-0-6. Only rule M5-0-4 is shown.

Troubleshooting

If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Expressions
Category: Required, Automated

Version History

Introduced in R2019a