Show/Hide Toolbars

XSharp

Narrowing conversion from 'type 1' to 'type 2' may lead to loss of data or overflow errors

 

Example

This warning may occur in code where you assigning a value from a larger type into a smaller type

The warning will only be shown when you compile with the compiler option /vo11 (Compatible Numeric Conversions).

Without this compiler option the error XS0266 (Cannot implicitly convert type 'type 1' to 'type 2'. An explicit conversion exists (are you missing a cast?)) will be shown.

 

FUNCTION Test() AS VOID
LOCAL dw as DWORD
LOCAL b as BYTE
dw := SomeFunctionThatReturnsADword()
b := dw               // warning XS9020 Narrowing conversion from 'DWORD' to 'BYTE' may lead to loss of data or overflow errors