Miscellaneous-NoPrecisionLoss

Do not assign longer data types to shorter ones

Required inputs: IR

This rule will warn on implicit conversions from larger types to shorter types. Use an explicit conversion to make it clear that the conversion may cause loss of precision.
Example
short int_to_short(int i)
{
    return i; // BAD

    return (short)i; // OK
}

Possible Messages

Key

Text

Severity

Disabled

precision_loss

{} with loss of precision.

None

False

Options

message_anchor

message_anchor

Type: dict[bauhaus.ir.PIR_Class_Name, AnchorKind]

Default: {}

Allows to choose between lhs, rhs, and asgn (default) node as anchor where the message should be reported, distinguished by PIR node type of the assignment kind.
 

Option Types

These types are used by options listed above:

AnchorKind

An enumeration.
 
  • lhs

  • rhs

  • asgn