|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
42 - 16 = ?
Subscribe to this entry?

 [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: Tue Jun 25 02:01:28 2024 UTC