[php-src] Issue #10195: Incorrect arithmetic calculations when using JIT

From: Date: Sat, 31 Dec 2022 03:33:50 +0000
Subject: [php-src] Issue #10195: Incorrect arithmetic calculations when using JIT
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243294@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10195 Author: GajowyJ ### Description The problem is hard to reproduce because it depends on the code previously executed in an incomprehensible way. I have a function like below: ```php <?php function Tangential2XY($tang,$sol) { print("=>Tangential2XY\n"); var_dump($tang,$sol); $x = $sol['X']['k']*$tang['KSI'] + $sol['X']['e']*$tang['ETA'] + $sol['X'][1]; $y = $sol['Y']['k']*$tang['KSI'] + $sol['Y']['e']*$tang['ETA'] + $sol['Y'][1]; $x = $sol['xc']*($x+1); $y = $sol['yc']*($y+1); var_dump($x,$y); return ['x'=>$x,'y'=>$y]; ``` For exactly the same input data I got different results, depending on the previous operations executed. Switching off JIT (opcache.enable_cli=0) producess correct results. Resulted (sometimes) in this output: ``` =>Tangential2XY array(2) { ["KSI"]=> float(-0.0001819685080039859) ["ETA"]=> float(8.862282985990099E-5) } array(8) { ["X"]=> array(3) { ["k"]=> float(-222.47396149883136) ["e"]=> float(-8.132167973459502) [1]=> float(-0.033852713544306225) } ["Y"]=> array(3) { ["k"]=> float(-14.389222777371765) ["e"]=> float(393.0672227450047) [1]=> float(-0.034318122126483344) } ["rRA0"]=> float(1.0777157410495175) ["cosDEC0"]=> float(0.5485071919403858) ["sinDEC0"]=> float(0.8361458367950371) ["xc"]=> int(968) ["yc"]=> int(548) ["spp"]=> float(0.957071427611752) } float(1.0059098455606683) float(1.0031349928784863) ``` But I expected this output instead: ``` =>Tangential2XY array(2) { ["KSI"]=> float(-0.0001819685080039859) ["ETA"]=> float(8.862282985990099E-5) } array(8) { ["X"]=> array(3) { ["k"]=> float(-222.47396149883136) ["e"]=> float(-8.132167973459502) [1]=> float(-0.033852713544306225) } ["Y"]=> array(3) { ["k"]=> float(-14.389222777371765) ["e"]=> float(393.0672227450047) [1]=> float(-0.034318122126483344) } ["rRA0"]=> float(1.0777157410495175) ["cosDEC0"]=> float(0.5485071919403858) ["sinDEC0"]=> float(0.8361458367950371) ["xc"]=> int(968) ["yc"]=> int(548) ["spp"]=> float(0.957071427611752) } float(973.720730502727) float(549.7179760974104) ``` ### PHP Version PHP 8.0.26 ### Operating System Windows 10

« previous php.bugs (#243294) next »