Bug #69038 [NEW]: switch(SOMECONSTANT) misbehaves

From: Date: Thu, 12 Feb 2015 08:43:19 +0000
Subject: Bug #69038 [NEW]: switch(SOMECONSTANT) misbehaves
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190607@lists.php.net to get a copy of this message
From: php at bof dot de Operating system: Linux PHP version: 5.6.5 Package: opcache Bug Type: Bug Bug description:switch(SOMECONSTANT) misbehaves Description: ------------ Using a self built PHP 5.6.5, opcache enabled: switch(ARBITRARYCONSTANTS) misbehaves: goes to the default case, unless the matching thing is the first case. opcache is enabled like this: zend_extension=/opt/php/extensions/opcache.so opcache.enable_cli=1 Also happens under mod_php without opcache.enable_cli. No other opcache settings made, but happens also with our usual production settings, so that should not matter The result is usually what I show under "actual result", below, but on some runs I also see a segmentation fault, or the correct behaviour. I can reproduce the problem when using global "const MYCONST = 'foo';", but apparently _not_ with a class constant (class foo { const MYCONST = 'foo'; } Will create a debug build of PHP soon and try to capture a backtrace for a test run where it runs into a segmentation violation. Might take some time, though... Test script: --------------- <?php define('MYCONST', 'foo'); function goodswitch() { switch(MYCONST) { case 'foo': return 'foo'; case 'bar': return 'bar'; default: return 'default'; } } function badswitch() { switch(MYCONST) { case 'bar': return 'bar'; case 'foo': return 'foo'; default: return 'default'; } } var_dump(goodswitch()); var_dump(badswitch()); ?> Expected result: ---------------- string(3) "foo" string(3) "foo" Actual result: -------------- string(3) "foo" string(7) "default" -- Edit bug report at https://bugs.php.net/bug.php?id=69038&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69038&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69038&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69038&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69038&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69038&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69038&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69038&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69038&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69038&r=support Expected behavior: https://bugs.php.net/fix.php?id=69038&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69038&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69038&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69038&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69038&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69038&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69038&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69038&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69038&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69038&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69038&r=mysqlcfg

« previous php.bugs (#190607) next »