[phc-general] static members initialized with constant arrays

Gary Wassermann wassermann at ucdavis.edu
Wed Nov 7 18:40:18 GMT 2007

I have a class with a method that has a static member that gets
initialized to an array value.  For some reason, phc fails on it and
gives the following error message:

Default value of a static declaration must be a literal value or an

I looked at the phc source code, and it seems the following check is
failing (from Invalid_check.cpp):
return ( dynamic_cast <AST_literal*> (in)
                                || dynamic_cast <AST_array*> (in)
                                || dynamic_cast <AST_constant*> (in));

The code has roughly the following structure:
	// names have been changed to protect the innocent
	// extraneous code has been removed
        class C {
        function M($t,$l=-1,$f=false)
            static $tM = array(
                'V' => 'C',
                'V2' => 'C',

I'm not using the latest revision of phc, so it could have been fixed
there, but I haven't seen anything about this case on the list since I
got my version, so I assume it has not.

Gary Wassermann <wassermann at ucdavis.edu>

More information about the phc-general mailing list