BEGIN (UN)CHECKED 和 END (UN)CHECKED 关键字标记启用或禁用溢出检查的编译语句块
BEGIN CHECKED
statements
END CHECKED
BEGIN UNCHECKED
statements
END CHECKED
statements | 编译时使用指定溢出检查的一条或多条语句或表达式 |
BEGIN CHECKED ... END CHECKED 可确保在编译代码块时使用明确的溢出检查选项,与编译器选项 -ovf 无关。
BEGIN CHECKED
LOCAL intValue as INT
LOCAL dwordValue as DWORD
intValue := -1
dwordValue := (DWORD) intValue // 溢出错误
END CHECKED
BEGIN UNCHECKED
LOCAL intValue as INT
LOCAL dwordValue as DWORD
intValue := -1
dwordValue := (DWORD) intValue // 无溢出错误,dwordValue 现在的值为 UInt32.MaxValue
END UNCHECKED