THRIFT-4642 FPU ctrl word settings may cause an unexpected "denormalized" error
Client: Delphi
Patch: Jens Geyer
diff --git a/lib/delphi/src/Thrift.Protocol.Compact.pas b/lib/delphi/src/Thrift.Protocol.Compact.pas
index 5b1253a..1c1b3da 100644
--- a/lib/delphi/src/Thrift.Protocol.Compact.pas
+++ b/lib/delphi/src/Thrift.Protocol.Compact.pas
@@ -1088,11 +1088,29 @@
 {$ENDIF}
 
 
+{$IFDEF Debug}
+procedure UnitTest;
+var w : WORD;
+const FPU_CW_DENORMALIZED = $0002;
+begin
+  w := Get8087CW;
+  try
+    Set8087CW( w or FPU_CW_DENORMALIZED);
+
+    TestDoubleToInt64Bits;
+    TestZigZag;
+    TestLongBytes;
+
+  finally
+    Set8087CW( w);
+  end;
+end;
+{$ENDIF}
+
+
 initialization
   {$IFDEF Debug}
-  TestDoubleToInt64Bits;
-  TestZigZag;
-  TestLongBytes;
+  UnitTest;
   {$ENDIF}
 
 end.