Recent

Author Topic: {$OVERFLOWCHECKS ON} does not report an obvious overflow  (Read 8937 times)

Lupp

  • New Member
  • *
  • Posts: 31
Re: {$OVERFLOWCHECKS ON} does not report an obvious overflow
« Reply #15 on: February 08, 2017, 11:41:55 pm »
@Nitorami
Thank you for the information.
This finally makes sense.

Other information I found myself in the web was often misleading with this respect.

Regards

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9870
  • Debugger - SynEdit - and more
    • wiki
Re: {$OVERFLOWCHECKS ON} does not report an obvious overflow
« Reply #16 on: February 09, 2017, 12:25:24 am »
Yes, {$Q+} has an effect, but not the one you expect. The directive tells FPC to terminate program with error 215 in case of an arithmetic overflow in the CPU
"terminate program with error 215"

Overflow can also happen at compile time.
Try
Code: Pascal  [Select][+][-]
  1. i32:= high(qword) + 2;
This exceeds the 65 bit. So it gives overflow.

But otherwise you are right

Overflow: happens in the math operation (here: addition)
Range Check: happens in the assignment

 

TinyPortal © 2005-2018