ARudik / phc

Automatically exported from code.google.com/p/phc
0 stars 0 forks source link

$php_errormsg is not working inside a function #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello

Here is a script to reproduce the bug :

<?php
function show_error()
{
        @strpos();
        $error_message = $php_errormsg;
        echo "inside the function : $error_message \n";
}
show_error();
?>

With the php cli it works, but the same script compiled with phc does not
works.

What steps will reproduce the problem?
1. I put what I do on a attach file

What version of the product are you using? On what operating system?
Slackware 13.0 x86 32bits
PHP 5.2.11 and 5.2.10
PHC 0.2.0.3

Thanks

Original issue reported on code.google.com by jeanroch...@gmail.com on 5 Oct 2009 at 12:24

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the report. Try the following patch:

Index: src/optimize/Prune_symbol_table.cpp
===================================================================
--- src/optimize/Prune_symbol_table.cpp (revision 3300)
+++ src/optimize/Prune_symbol_table.cpp (working copy)
@@ -111,6 +111,11 @@
                // record variable names for removing globals
                if (record_globals)
                        (*vars)[*in->value] = true;
+
+               // Dont do this optimization in the presence of php_errormsg.
+               // There are much better ways of doing this, but this is the 
simplest.
+               if (*in->value == "php_errormsg")
+                       prune = false;
        }

        void post_variable_variable (Variable_variable* in)

It seems to work for me, but I'm running more tests now to make sure it doesnt 
break
anything.

Original comment by paul.biggar on 5 Oct 2009 at 1:33

GoogleCodeExporter commented 9 years ago
Thanks,
yes it is working for me too :)
and also in a function call by another function

Original comment by jeanroch...@gmail.com on 5 Oct 2009 at 4:14

GoogleCodeExporter commented 9 years ago
OK, fix committed in revision 3301.

Thanks for the report and verification.

Original comment by paul.biggar on 5 Oct 2009 at 5:33