php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17899 (Probably) Bug in zend parser
Submitted: 2002-06-21 10:41 UTC Modified: 2002-06-22 10:32 UTC
From: othalla at wp dot pl Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.1 OS: linux RH6.1
Private report: No CVE-ID: None
 [2002-06-21 10:41 UTC] othalla at wp dot pl
In zend_language_parser.y there is code:

[...]
static_scalar: /* compile-time evaluated scalars */                                                            
[...] 
        |       '+' static_scalar       { $$ = $1; } 
[...]

but I think that schould be:

[...]
static_scalar: /* compile-time evaluated scalars */                                                            
[...] 
        |       '+' static_scalar       { $$ = $2; } 
[...]

-----------------------------------------------------

           $2      instead of      $1  


It's still in PHP 4.3.0-alpha tarball.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-21 12:15 UTC] sander@php.net
This is a Zend Engine 2 problem I guess...
Can you elaborate on this 'bug'? Why do you think it's wrong? Can you show us a script, etc...
 [2002-06-22 10:03 UTC] carldrinkwater at mac dot com
Well, you would expect yacc to return the static_scalar 
rather than the '+' of this rule ... Here is a script that 
demonstrates the problem ...

<?
  static $a = +1;
  static $b = -1;

  echo $a."\n";
  echo $b."\n";
?>


This gives the output ...

2969616
-1


Which as you can see, isn't entirely correct!
 [2002-06-22 10:20 UTC] carldrinkwater at mac dot com
This is in fact a bug, and changing the grammar file as 
suggested by othalla@wp.pl fixes this problem.  Here is a 
diff to do it ...


--- zend_language_parser.y      Sat Jun 22 15:12:41 2002
+++ zend_language_parser.old    Sat Jun 22 15:18:26 2002
@@ -608,7 +608,7 @@
 static_scalar: /* compile-time evaluated scalars */
                common_scalar           { $$ = $1; }
        |       T_STRING                { 
zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT TSRMLS_CC); 
}
-       |       '+' static_scalar       { $$ = $2; }
+       |       '+' static_scalar       { $$ = $1; }
        |       '-' static_scalar       { zval minus_one;  
minus_one.type = IS_LONG; minus_one.value.lval = -1;  
mul_function(&$2.u.constant, &$2.u.constant, &minus_one 
TSRMLS_CC);  $$ = $2; }
        |       T_ARRAY '(' static_array_pair_list ')' { $$ 
= $3; $$.u.constant.type = IS_CONSTANT_ARRAY; }
        |       parse_class_name_entry T_STRING { 
zend_do_fetch_constant(&$$, &$1, &$2, ZEND_CT TSRMLS_CC); }
 [2002-06-22 10:32 UTC] andi@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

Thanks for the bug report and fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC