Bug #77347 [NEW]: switch catsing behavior by setlocale(LC_NUMERIC, '') is wrong

From: Date: Wed, 26 Dec 2018 14:32:13 +0000
Subject: Bug #77347 [NEW]: switch catsing behavior by setlocale(LC_NUMERIC, '') is wrong
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218620@lists.php.net to get a copy of this message
From: spam2 at rhsoft dot net Operating system: Linux PHP version: 7.2.13 Package: Scripting Engine problem Bug Type: Bug Bug description:switch catsing behavior by setlocale(LC_NUMERIC, '') is wrong Description: ------------ you can disable comments for https://bugs.php.net/bug.php?id=77278 as much as you want - the current behavior of the scriptiung language is plain wrong and this seems have to be fixed even in the past looking at https://bugs.php.net/bug.php?id=17815 and "Workaround for this bug: setlocale(LC_NUMERIC,'C');" * LC_NUMERIC="de_DE.UTF-8" is the default environment here * if you call the changing behavior depending on locale correct you mustn't silently change it to LC_NUMERIC=C to begin with and that code sample would always come with , instead . * but it does not * it does only after a random setlocale wihtin PHP or some library [harry@srv-rhsoft:/downloads]$ locale LANG=de_DE.UTF-8 LC_CTYPE="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_COLLATE="de_DE.UTF-8" LC_MONETARY="de_DE.UTF-8" LC_MESSAGES="de_DE.UTF-8" LC_PAPER="de_DE.UTF-8" LC_NAME="de_DE.UTF-8" LC_ADDRESS="de_DE.UTF-8" LC_TELEPHONE="de_DE.UTF-8" LC_MEASUREMENT="de_DE.UTF-8" LC_IDENTIFICATION="de_DE.UTF-8" LC_ALL= [harry@srv-rhsoft:/downloads]$ php /downloads/casting.php LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C OK: 4 de_DE.UTF-8 FAIL: 3,3333333333333 Test script: --------------- [harry@srv-rhsoft:/downloads]$ cat /downloads/casting.php <?php declare(strict_types=1); echo setlocale(LC_ALL, '0'), "\n"; $pages_summary = (string)(10 / 3); if($pages_summary > (int)$pages_summary) { $pages_summary = (int)$pages_summary + 1; } if((int)$pages_summary !== 4) { echo "FAIL: $pages_summary\n"; } else { echo "OK: $pages_summary\n"; } echo "\n"; echo setlocale(LC_NUMERIC, ''), "\n"; $pages_summary = (string)(10 / 3); if($pages_summary > (int)$pages_summary) { $pages_summary = (int)$pages_summary + 1; } if((int)$pages_summary !== 4) { echo "FAIL: $pages_summary\n"; } else { echo "OK: $pages_summary\n"; } Expected result: ---------------- no change in casting behavior Actual result: -------------- don't change internal behavior randomly -- Edit bug report at https://bugs.php.net/bug.php?id=77347&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77347&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77347&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77347&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77347&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77347&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77347&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77347&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77347&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77347&r=support Expected behavior: https://bugs.php.net/fix.php?id=77347&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77347&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77347&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77347&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77347&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77347&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77347&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77347&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77347&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77347&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77347&r=mysqlcfg

« previous php.bugs (#218620) next »