#31174 [Opn->Csd]: const compile warning in url.c
| From: | iliaa@php.net | Date: | Mon, 20 Dec 2004 19:29:40 +0000 |
| Subject: | #31174 [Opn->Csd]: const compile warning in url.c | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-70719@lists.php.net to get a copy of this message | ||
ID: 31174
Updated by: iliaa@php.net
Reported By: lukem at NetBSD dot org
-Status: Open
+Status: Closed
Bug Type: Compile Warning
Operating System: NetBSD
PHP Version: 4.3.10
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-12-19 23:36:31] lukem at NetBSD dot org
The error:
ext/standard/url.c: In function `php_url_parse_ex':
ext/standard/url.c:102: warning: assignment discards qualifiers from
pointer target type
The cause of the error is obvious; in the function php_url_parse_ex():
+ the function argument str is declared as 'char const *str'
+ the variable s is declared as 'char *s'
+ the assignement statement in line 102 is:
s = str;
which attempts to lose the "const"ness of str.
It turns out that all the 'char *' variables used in this function can
be 'const char *' (or in php-use, 'char const *' -- same thing,
although the former is the common idiom) because those variables refer
to str (or derivatives) and don't need to modify the variable.
I solved the warnings locally by adding the 'const' qualifier to the
variable declaration for s,e,p,pp,ee
as I mentioned in my first comment.
------------------------------------------------------------------------
[2004-12-19 20:22:57] iliaa@php.net
Can you please show the exact warnings you are seeing.
------------------------------------------------------------------------
[2004-12-18 04:09:12] lukem at NetBSD dot org
Description:
------------
ext/standard/url.c::php_url_parse_ex() uses 'char *' pointers at
various places where 'char const *' (aka 'const char *') pointers
should be used instead. This causes problems when compiling php with a
higher level of compiler warnings.
The fix is trivial. Replace line 100 of ext/standard/url.c:
char *s, *e, *p, *pp, *ue;
with
char const *s, *e, *p, *pp, *ue;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31174&edit=1