Pro of using TO_<TYPE> could be the comparison of two variables of different User Data Types, by casting themselves to the common known type, so to avoid that the compiler alerts you about implicit data type conversion. Example:
TYPE E_SYSTEM_STATE :(
ALARM := -1 ,
STOP := 0 ,
RUNNING := 1
)INT;
END_TYPE
TYPE E_SUBSYSTEM_STATE :(
ALARM := -1 ,
STOP := 0 ,
RUNNING := 1
)INT;
END_TYPE
We created two enum types that are identically, except for the scope for which they are defined (in this case they refer two different object of a state machine). Now we create the instance variables:
PROGRAM MAIN
VAR
eSysState : E_SYSTEM_STATE;
eSubsysState : E_SUBSYSTEM_STATE;
bCheck : BOOL;
END_VAR
//
bCheck := (eSysState = eSubsytState);
As you can see, even if the variables eState and eSubsysState are both derived from basic type INT (as declared within the Enum type), after building the solution, the last line cause the compiler to generate a C0354 alert:
Sure, you have several ways to get around this, but one simple way is to cast both the variables to the same native basic data. So the final instruction becomes something like this and the compiler stops to generate the alert:
bCheck := TO_INT(eSysState) = TO_INT(eSubsytState);