Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now
This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.
This diagnostic rule is relevant only for C.
The MISRA C standard defines its own type model, called the essential type model.
The values used in expressions should have appropriate essential types.
The C language has no restrictions on operations with basic types, but some of these operations may lead to unspecified/undefined behavior, or make no sense at all.
For example:
Boolean type index;Implicit conversion to Boolean may also be dangerous, since not all decimals may be represented in the binary number system.
void Foo(float f, _Bool other_expr)
{
if (f || other_expr) ....
}
The following table gives intersections of operands and operations types, which should not be composed in expressions. These intersections are marked with an X.

The example:
void Foo(float f, _Bool b, int a[], enum E e)
{
if (~a[(e ? 1 : 2) >> (-b * f --> +b) << signed(-24U)]) ....;
}
Exception. Expression of a signed type with a positive value can be used as the right-hand operand of a shift operator (>>, <<).
void foo(signed vi, unsigned _)
{
assert(vi >= 0);
_ >> vi;
_ << vi;
}
This diagnostic is classified as:
|
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: