beckhoff TE1200 — 4.2.1.6.6 SA0130: Implicit expanding conversions

Configuration | Rules bPointer := pStruct^.bTest; // => SA0039: Possible null pointer dereference 'pStruct^' bRef := refStruct.bTest; // => SA0145: Possible use of not initialized reference 'refStruct' IF pStruct 0 THEN bPointer := pStruct^.bTest; // no error SA0039 as the pointer is checked for unequal 0 END_IF IF __ISVALIDREF(refStruct) THEN bRef := refStruct.bTest; // no error SA0145 as the reference is checked via __ISVALIDREF END_IF Overview of the rules on "dereferencing" 4.2.1.6.6 SA0130: Implicit expanding conversions | SA0130: Implicit expanding conversions Samples: PROGRAM MAIN VAR nDINT : DINT; nLINT : LINT; nUSINT : USINT; nUINT : UINT; nUDINT : UDINT; nULINT : ULINT; nLWORD :

LWORD; TE1200 67 Version: 2.11.1 Pointer Dereferencing of pointers in the declaration part SA0124: Dereference access in initializations [} 66] Possible null pointer dereferences in the implementation part SA0039: Possible null pointer dereferences [} 37] References Use of references in the declaration part SA0125: References in initializations [} 66] Possible use of not initialized reference in the implementation part SA0145: Possible use of not initialized references [} 69] Interfaces Possible use of not initialized interface in the implementation part SA0046:

Possible use of not initialized interfaces [} 41] Function Determines code positions where conversions from smaller to larger data types are implicitly carried out during arithmetic operations. Reason The compiler allows any assignment of different types if the range of the source type is fully within the range of the target type. However, the compiler will build a conversion into the code as late as possible. For an assignment of the following type: nLINT := nDINT * nDINT; the compiler performs the implicit conversion only after the multiplication: nLINT := TO LINT(nDINT * nDINT); _ An overflow is therefore truncated.

If you want to prevent this, you can have the conversion performed earlier for the elements: nLINT := TO LINT(nDINT) * TO LINT(nDINT); _ _ Therefore, it may be useful to report points where the compiler implements implicit conversions in order to check whether these are exactly what is intended. In addition, explicit conversions can serve to improve portability to other systems if they have more restrictive type checks. Exception BOOL ↔ BIT Importance Low