php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44355 compilation breaks due illegal const usage
Submitted: 2008-03-06 22:31 UTC Modified: 2008-03-08 16:45 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gk at gknw dot de Assigned: pajoye (profile)
Status: Closed Package: EXIF related
PHP Version: 5.2CVS-2008-03-06 (CVS) OS: NetWare
Private report: No CVE-ID: None
 [2008-03-06 22:31 UTC] gk at gknw dot de
Description:
------------
The NetWare compiler we use is very strict and breaks when const is used where not expected. The commit:
http://cvs.php.net/viewvc.cgi/php-src/ext/exif/exif.c?r1=1.196&r2=1.197
breaks the NetWare compile due to the line:
static const zend_module_dep exif_module_deps[] = {

exif.c:258: illegal implicit conversion from 'const struct 
exif.c:258: _zend_module_dep[2]' to
exif.c:258: 'struct _zend_module_dep *'

the patch below fixes this and also adds ifdefs as used with other extensions f.e. pdp_*; not sure if these are really needed, but this change:
-static const zend_module_dep exif_module_deps[] = {
+static zend_module_dep exif_module_deps[] = {
is definetely required.

--- exif.c.orig	Mon Dec 31 08:33:29 2007
+++ exif.c	Thu Mar 06 23:15:31 2008
@@ -242,19 +242,25 @@
 /* }}} */
 
 /* {{{ exif dependencies */
-static const zend_module_dep exif_module_deps[] = {
+#if ZEND_MODULE_API_NO >= 20050922
+static zend_module_dep exif_module_deps[] = {
 	ZEND_MOD_REQUIRED("standard")
 #if EXIF_USE_MBSTRING
 	ZEND_MOD_REQUIRED("mbstring")
 #endif
 	{NULL, NULL, NULL}
 };
+#endif
 /* }}} */
 
 /* {{{ exif_module_entry
  */
 zend_module_entry exif_module_entry = {
+#if ZEND_MODULE_API_NO >= 20050922
 	STANDARD_MODULE_HEADER_EX, NULL,
+#else
+	STANDARD_MODULE_HEADER,
+#endif
 	exif_module_deps,
 	"exif",
 	exif_functions,





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-07 18:57 UTC] pajoye@php.net
Applied to 5.2 (and head) only for now. But this is a temporary fix. The error returned on the Novell platform makes little sense. We can't drop this const usage only because of Novell. We'll try to figure out what's wrong and how to achieve the same thing and keep novell happy ;)
 [2008-03-07 19:33 UTC] gk at gknw dot de
From what I see the Metrowerks compiler is right when it finds a type mismatch - what's wrong is that it errors out instead of only warn, but unfortunately this cant the changed with a compiler switch.
Looking at ./Zend/zend_modules.h I see struct _zend_module_entry declared as:
struct _zend_module_entry {
	unsigned short size;
	unsigned int zend_api;
	unsigned char zend_debug;
	unsigned char zts;
	struct _zend_ini_entry *ini_entry;
	struct _zend_module_dep *deps;
	char *name;
....

if I change the struct to use 'const zend_module_dep *':
--- zend_modules.h.orig	Mon Dec 31 08:33:26 2007
+++ zend_modules.h	Fri Mar 07 20:10:34 2008
@@ -80,7 +80,7 @@
 	unsigned char zend_debug;
 	unsigned char zts;
 	struct _zend_ini_entry *ini_entry;
-	struct _zend_module_dep *deps;
+	const struct _zend_module_dep *deps;
 	char *name;
 	struct _zend_function_entry *functions;
 	int (*module_startup_func)(INIT_FUNC_ARGS);

then it works fine with unchanged exif.c extension; however sure it breaks then with _every_ other module since none currently use 'const zend_module_dep', at least not in PHP 5.2 source tree.
So if we want the modules use 'const zend_module_dep' then the header zend_modules.h must also be changed, and it must be done for _all_ modules.
 [2008-03-08 16:45 UTC] gk at gknw dot de
Closing the bug now since I've just checked that current RC3 snapshot from today builds fine. Thanks Pierre!
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 28 20:01:25 2020 UTC