#30285 [NEW]: switch statement: default executed when case matches
| From: | benjcarson at digitaljunkies dot ca | Date: | Thu, 30 Sep 2004 03:25:27 +0000 |
| Subject: | #30285 [NEW]: switch statement: default executed when case matches | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-66916@lists.php.net to get a copy of this message | ||
From: benjcarson at digitaljunkies dot ca
Operating system: Debian Linux
PHP version: 5CVS-2004-09-30 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: switch statement: default executed when case matches
Description:
------------
It seems that the default: block of a switch statement now short-circuits
the remaining case: tests. If the default: block is put before a matching
case: block, it will _always_ be executed. While the docs
(http://www.php.net/manual/en/control-structures.switch.php) do recommend
making default: last, this is a BC break (tested with 5.0.0 and 4.3.2).
This bug is also present at least as early as the 5.1.x-dev 2004-09-25
snap (sorry, the next earliest one I have is 5.0.0).
The reproduce code below works if the default: block is put after the case
"a": block.
Reproduce code:
---------------
<?php
$x = "a";
switch ($x) {
default:
echo "default\n";
break;
case "a":
echo "case: a\n";
break;
}
?>
Expected result:
----------------
case: a
Actual result:
--------------
default
--
Edit bug report at http://bugs.php.net/?id=30285&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30285&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30285&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30285&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30285&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30285&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30285&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30285&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30285&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30285&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30285&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30285&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30285&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30285&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30285&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30285&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30285&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30285&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30285&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30285&r=mysqlcfg