php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26078 Comparison always false in var_unserializer.c
Submitted: 2003-11-02 07:16 UTC Modified: 2003-11-03 14:09 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: AxelLuttgens at swing dot be Assigned:
Status: Wont fix Package: Compile Warning
PHP Version: 4.3.3 OS: Darwin 7.0.0 (Panther)
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: AxelLuttgens at swing dot be
New email:
PHP Version: OS:

 

 [2003-11-02 07:16 UTC] AxelLuttgens at swing dot be
Description:
------------
I know this has already been reported, with reassuring replies such as "that warning may be safely ignored" or "there is no need to fix this one".

A a reminder, the message goes so:

var_unserializer.c:308: warning: comparison is always false due to limited range of data type

(I tried with PHP 4.3.3, as well as with php4-STABLE-200311020830: same results)

I am of the opinion that it is just lucky programming that it works now, and that the whole matter could easily break in case of a slight change in the code.

I don't know much about re2c, but I think I can guess how it works by comparing the .re and the resulting .c files.
So, looking at the var_unserializer.re file, these lines seem to be the relevant ones:

0086: #define YYCTYPE unsigned char
0097: any = [\000-\277];
0411: any	{ return 0; }
0415: 	return 0;

Corresponding lines in var_unserializer.c are:

0087: #define YYCTYPE unsigned char
0308:                 if(yych <= '\277') goto yy15;
0309:             }
0310:         }
0311:     }
0312: yy2: YYCURSOR = YYMARKER;
0313:     switch(yyaccept){
0314:     case 0: goto yy4;
0315:     }
0319: yy4:
0320:     { return 0; }
0359: yy15: yych = *++YYCURSOR;
0360:     goto yy4;

In the comparison, yych is promoted to an unsigned in, while (on lots of systems) '\277' is promoted to a signed int, hence the comparison failure.

Now, the lucky part is that yyaccept is never set in the code and thus keeps its initialisation value (ie, zero).
So, jumping to yy15 or continuing execution through yy2 have finally the same effect...

But the question is: shouldn't the any symbol be defined as 
[\000-\377] instead of [\000-\277]?

If it is the case, I guess re2c would just forget about comparisons with characters having decimal code greater than 127.
And one would thus alleviate spurious warnings.

If it isn't the case, well, my apologies ;-)

HTH
Axel



Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 11:01:27 2024 UTC