Abs() doesn't raise an range exception errror for min integer

Summary

With range checking enabled, the Abs() function doesn't raise an error when being called with Integer.MinValue.

System Information

  • Operating system: Windows
  • Processor architecture: x86_64
  • Compiler version: 3.3.1
  • Device: Computer

Steps to reproduce

see example below

Example Project

program abs_test;

uses SysUtils;

var x: Int64;

{$RANGECHECKS ON}

begin
  x := Abs(Integer.MinValue);
  Writeln (x);
  // no error, result is -2147483648
end.

What is the current bug behavior?

Because of the asymmetry of signed integers, the Abs() function cannot compute the absolute value of -2147483648. This is ok. However, having range checking enabled, this case isn't trapped: no error occurs.

What is the expected (correct) behavior?

With range checking enabled, a range check error should happen.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information