Bookstore

Recent

Author Topic: Run-Time Error. How does it work?  (Read 156 times)

wuguwoxu

  • Newbie
  • Posts: 1
Run-Time Error. How does it work?
« on: March 26, 2020, 12:13:01 pm »
Hello.
The program runs without visible errors and messages about them if compiled in release mode

If in debug mode it crashes with an error
Quote
215 Arithmetic overflow error
This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows.
This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation.
I figured it out.

This is not clear
1. Why is there no error in the "release" mode. Is it turned on / off somewhere?
2. I.e. There is no error, but the calculation results are distorted.
it turns out that everything that does not fit in the allocated number of bytes is simply truncated. Right?

Handoko

  • Hero Member
  • *****
  • Posts: 3434
  • My goal: build my own game engine using Lazarus
Re: Run-Time Error. How does it work?
« Reply #1 on: March 26, 2020, 12:32:53 pm »
Hello wuguwoxu,
Welcome to the forum.

If you use Lazarus, overflow check can be turn on/off by:
Lazarus main menu > Project > Project Options > Compiler Options > Debugging > Overflow (-Co)

You may also need to enable Range Check.

Release mode means to turn off all checks. When overflow happens, it does not simply means the result is truncated. The result can be wrapper or (for some rare cases) clamped.

https://en.wikipedia.org/wiki/Integer_overflow
« Last Edit: March 26, 2020, 01:00:31 pm by Handoko »