Browse Source

* (non-ancient) Delphi versions that accept explicit ordinal -> floating
point typecasts behave the same as FPC (convert the value) rather than
as Turbo Pascal (reinterpret the bit pattern) (mantis #35886)

git-svn-id: trunk@42507 -

Jonas Maebe 6 years ago
parent
commit
1da43f67d4
3 changed files with 20 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/defcmp.pas
  3. 17 0
      tests/webtbs/tw35886.pp

+ 1 - 0
.gitattributes

@@ -17770,6 +17770,7 @@ tests/webtbs/tw3578.pp svneol=native#text/plain
 tests/webtbs/tw3579.pp svneol=native#text/plain
 tests/webtbs/tw3583.pp svneol=native#text/plain
 tests/webtbs/tw35862.pp svneol=native#text/pascal
+tests/webtbs/tw35886.pp svneol=native#text/plain
 tests/webtbs/tw3589.pp svneol=native#text/plain
 tests/webtbs/tw3594.pp svneol=native#text/plain
 tests/webtbs/tw3595.pp svneol=native#text/plain

+ 2 - 2
compiler/defcmp.pas

@@ -808,9 +808,9 @@ implementation
                case def_from.typ of
                  orddef :
                    begin { ordinal to real }
-                     { only for implicit and internal typecasts in tp/delphi }
+                     { only for implicit and internal typecasts in tp }
                      if (([cdo_explicit,cdo_internal] * cdoptions <> [cdo_explicit]) or
-                         ([m_tp7,m_delphi] * current_settings.modeswitches = [])) and
+                         (not(m_tp7 in current_settings.modeswitches))) and
                         (is_integer(def_from) or
                          (is_currency(def_from) and
                           (s64currencytype.typ = floatdef))) then

+ 17 - 0
tests/webtbs/tw35886.pp

@@ -0,0 +1,17 @@
+program project1;
+
+{$mode delphi}
+
+uses
+  SysUtils;
+
+var
+  f: Double;
+  n: Int64;
+
+begin
+  n := 9876543210;
+  f := Double(n);
+  if f<>9876543210.0 then
+    halt(1);
+end.