|  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
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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: AxelLuttgens at swing dot be
New email:
PHP Version: OS:


 [2003-11-02 07:16 UTC] AxelLuttgens at swing dot be
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 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:     }
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 ;-)



Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 09:01:30 2024 UTC