Bug #68643 [Nab]: Mathematical expression in class constant initialization causes crash

From: Date: Wed, 24 Dec 2014 22:27:08 +0000
Subject: Bug #68643 [Nab]: Mathematical expression in class constant initialization causes crash
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189186@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68643&edit=1 ID: 68643 User updated by: najamelan at autistici dot org Reported by: najamelan at autistici dot org Summary: Mathematical expression in class constant initialization causes crash Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 5.6.4 Block user comment: N Private report: N New Comment: Thanks for looking into it. I understand your reasoning, but time is precious on this end too and installing and configuring a different version of php and then switching back is quite expensive compared to someone saving a few lines of code into a file and running it. Btw I have a few more php/apache 500 errors to debug ;-( and switching to a newer version of php is not an option if our hoster won't follow suit. Why not create (or work together with) something like ideone.com to create an online service where users can test code against different versions of php? Previous Comments: ------------------------------------------------------------------------ [2014-12-24 20:58:57] aharvey@php.net This works fine on PHP 5.6.4, including the 5.6.4-1 package in Debian unstable. This is why we ask reporters to try the latest version. :) ------------------------------------------------------------------------ [2014-12-24 06:57:48] najamelan at autistici dot org Description: ------------ I'm sorry, I could only test this on 5.6.2-1 (debian) but it's very fast to verify for someone who has the latest version installed, see script below. Test script: --------------- <?php // php version 5.6.2-1 -> on debian const BLA = 1; class Test { const BLI = BLA * 5; // works on cli and crashes the interpreter on cgi (internal server error 500) // const BLI = 3 * 5; -> works fine on both cgi and cli but illegal according to the docs // https://wiki.php.net/rfc/const_scalar_exprs is said to be implemented in 5.6 // but neither the language specs nor the documentation reflect this. function __construct() { print_r( self::BLI ); // the interpreter only crashes when trying to access the constant } } new Test(); ?> Expected result: ---------------- 1. under no circumstance ever cause internal server 500 error (debugging nightmare) 2. update specs and docs Actual result: -------------- 500 in apache nothing in php error log ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68643&edit=1

« previous php.bugs (#189186) next »