php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31174 const compile warning in url.c
Submitted: 2004-12-18 04:09 UTC Modified: 2004-12-20 20:29 UTC
From: lukem at NetBSD dot org Assigned:
Status: Closed Package: Compile Warning
PHP Version: 4.3.10 OS: NetBSD
Private report: No CVE-ID:
 [2004-12-18 04:09 UTC] 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;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-19 20:22 UTC] iliaa@php.net
Can you please show the exact warnings you are seeing.
 [2004-12-19 23:36 UTC] 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-20 20:29 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 20:02:01 2014 UTC