Bookstore

Recent

Author Topic: Inconsistency between Windows and Linux compiling?  (Read 24402 times)

Laksen

  • Hero Member
  • *****
  • Posts: 639
    • J-Software
Re: Inconsistency between Windows and Linux compiling?
« Reply #15 on: July 03, 2011, 12:36:33 pm »
Does not work. Setting the ExceptionMask to empty set in program start creates many new exceptions and the application crashes.
Masking something means you don't want it to throw exceptions. So when you provide an empty exception mask it'll throw exceptions for every bad operation :)

If you set the mask to [exInvalidOp,exZeroDivide] then it won't throw exceptions when those things occur

Zoran

  • Hero Member
  • *****
  • Posts: 1504
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Inconsistency between Windows and Linux compiling?
« Reply #16 on: July 03, 2011, 12:44:14 pm »
Does not work. Setting the ExceptionMask to empty set in program start creates many new exceptions and the application crashes.
Masking something means you don't want it to throw exceptions. So when you provide an empty exception mask it'll throw exceptions for every bad operation :)

If you set the mask to [exInvalidOp,exZeroDivide] then it won't throw exceptions when those things occur

Okay, it certanly is a logical explanation. :)
However, I still find that this is not easy to control, I believe that this floating point behavior should be consistent on all platforms and widgetsets, I mean that it must be known what the default is and programmer should not set this exception mask depending on widgeset/OS, unless (s)he explicitely wants non-default behavior, don't you agree? So, I am going to make a bug report about this.

Thank you, Laksen.

Zoran

  • Hero Member
  • *****
  • Posts: 1504
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Inconsistency between Windows and Linux compiling?
« Reply #17 on: July 03, 2011, 01:41:07 pm »

Zoran

  • Hero Member
  • *****
  • Posts: 1504
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Inconsistency between Windows and Linux compiling?
« Reply #18 on: July 03, 2011, 09:15:51 pm »
This simple test:
Code: [Select]
uses
  ... math,...

var
  FPUException: TFPUException;
  FPUExceptionMask: TFPUExceptionMask; 
begin
  FPUExceptionMask := GetExceptionMask;
  writeln('Masked:');
  for FPUException := Low(TFPUException) to High(TFPUException) do begin
    if FPUException in FPUExceptionMask then begin
      write(' ', FPUException);
    end;
  end;
  writeln;
  writeln('Not masked:');
  for FPUException := Low(TFPUException) to High(TFPUException) do begin
    if not (FPUException in FPUExceptionMask) then begin
      write(' ', FPUException);
    end;
  end;
end; 
gives this output when we don't use Gtk2:

Masked:
 exDenormalized exUnderflow exPrecision
Not masked:
 exInvalidOp exZeroDivide exOverflow

With Gtk2, only exOverflow is not masked.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Inconsistency between Windows and Linux compiling?
« Reply #19 on: July 07, 2011, 12:38:56 am »
Nice write up in the wiki:)

Zoran

  • Hero Member
  • *****
  • Posts: 1504
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Inconsistency between Windows and Linux compiling?
« Reply #20 on: July 07, 2011, 10:30:57 pm »
Nice write up in the wiki:)

Thanks, Vincent. :)