php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81046 Literal compaction merges non-equal related literals
Submitted: 2021-05-17 11:39 UTC Modified: 2021-05-17 13:41 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: felix at felix-kolbe dot de Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 8.0.6 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: felix at felix-kolbe dot de
New email:
PHP Version: OS:

 

 [2021-05-17 11:39 UTC] felix at felix-kolbe dot de
Description:
------------
testet with 8.0.3 and 8.0.5

using a constant with upper-case(sic!) and the same name as a method result in "Call to undefined method" (and vice versa method overwrite constants)

Test script:
---------------
<?php
const fuN = 1;
new test;
class test{
	public function __construct() {
		fuN;
		$this->fun(); // prints	test->fun
		$this->fuN(); //Call to undefined method test::fuN()
		//fuN; coment this out for : Uncaught Error: Undefined constant "fuN"
	}
	function fun(){
		echo "<p>" . __CLASS__ . "->" . __FUNCTION__ .  "</p>";
	}
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-17 11:56 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: Class/Object related +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2021-05-17 11:56 UTC] cmb@php.net
I cannot reproduce[1].  Is there some "special" extension
involved?

[1] <https://3v4l.org/JuaDl>
 [2021-05-17 12:15 UTC] felix at felix-kolbe dot de
OK on bash its work, But not in Apache 

https://www.file-upload.net/download-14586850/PHP8.0.5-phpinfo.pdf.html

php -m
[PHP Modules]
Core
ctype
curl
date
dom
filter
gd
gmp
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
 [2021-05-17 12:23 UTC] felix at felix-kolbe dot de
as eval its work also but as script in Apache Environment(CGI) its produce the error as described above
 [2021-05-17 12:25 UTC] cmb@php.net
-Status: Feedback +Status: Open -Assigned To: cmb +Assigned To:
 [2021-05-17 12:25 UTC] cmb@php.net
Thanks for the further information.  This might be an OPcache
issue.
 [2021-05-17 12:34 UTC] felix at felix-kolbe dot de
OK, switching off OPCache prevents the error.
 [2021-05-17 12:40 UTC] nikic@php.net
-Status: Open +Status: Verified -Package: Scripting Engine problem +Package: opcache
 [2021-05-17 13:09 UTC] nikic@php.net
-Status: Verified +Status: Analyzed
 [2021-05-17 13:09 UTC] nikic@php.net
This is a bug in literal compaction. We merge a literal fuN/fuN for the constant with a literal fuN/fun for the method. It looks like the code currently assumes that literals with the same base literal and the same number of related literals must be the same, which is not the case here. I'm surprised this hasn't come up earlier, presumably it does hold for all the other literals.
 [2021-05-17 13:41 UTC] nikic@php.net
-Summary: constant overwrite class method +Summary: Literal compaction merges non-equal related literals -Assigned To: +Assigned To: nikic
 [2021-05-17 13:47 UTC] git@php.net
Automatic comment on behalf of nikic
Revision: https://github.com/php/php-src/commit/c446d68f7c9de6da8dc614ca4e065d81130d3956
Log: Fixed bug #81046
 [2021-05-17 13:47 UTC] git@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC