diff --git a/.gitattributes b/.gitattributes index 5341da6342..31939d5741 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10616,6 +10616,7 @@ tests/tbs/tb0606.pp svneol=native#text/pascal tests/tbs/tb0607.pp svneol=native#text/plain tests/tbs/tb0608.pp svneol=native#text/pascal tests/tbs/tb0609.pp svneol=native#text/plain +tests/tbs/tb0621.pp svneol=native#text/plain tests/tbs/tb205.pp svneol=native#text/plain tests/tbs/tb610.pp svneol=native#text/pascal tests/tbs/tb613.pp svneol=native#text/plain diff --git a/compiler/nadd.pas b/compiler/nadd.pas index 36c9659981..d3ff790e6b 100644 --- a/compiler/nadd.pas +++ b/compiler/nadd.pas @@ -697,8 +697,12 @@ implementation an slash expresion would be first converted into a multiplication and later folded } if (nodetype=slashn) and - { do not mess with currency types } - (not(is_currency(right.resultdef))) and + { do not mess with currency and comp types } + (not(is_currency(right.resultdef)) and + not((right.resultdef.typ=floatdef) and + (tfloatdef(right.resultdef).floattype=s64comp) + ) + ) and (((cs_opt_fastmath in current_settings.optimizerswitches) and (rt=ordconstn)) or ((cs_opt_fastmath in current_settings.optimizerswitches) and (rt=realconstn) and (bestrealrec(trealconstnode(right).value_real).SpecialType in [fsPositive,fsNegative]) diff --git a/tests/tbs/tb0621.pp b/tests/tbs/tb0621.pp new file mode 100644 index 0000000000..476d6af001 --- /dev/null +++ b/tests/tbs/tb0621.pp @@ -0,0 +1,27 @@ +PROGRAM compbug300; + +VAR x1, x2 : comp; + +(* Dividing 8 / 2 doesn't work with fpc 3.0.0 + but works for example with fpc 2.6.4 + Markus Greim / 29.jun.2016 *) + +BEGIN + +x1 := 8; +writeln('x1 : ',x1); +x2 := x1 / 2; +writeln('x2 = x1/2 should be 4 but is : ', x2); +if x2<>4 then + halt(1); +x2 := x1 / 4; +writeln('x2 = x1/4 should be 2 but is : ', x2); +if x2<>2 then + halt(2); +x2 := x1 / 8.0; +writeln('x2 = x1/8.0 should be 1 and is : ', x2); +if x2<>1 then + halt(3); + + +END.