I keep on having the following error:
    ERROR:
    ⋅ Incorrect Captcha
while trying to file a bug on the following page:
    https://bugs.php.net/report.php
(Debian sid, Google Chrome 14.0.835.186)

I tried flushing my cookies.
There are two opened bug reports about that:
 - https://bugs.php.net/bug.php?id=54380
 - https://bugs.php.net/bug.php?id=53255
And I would have liked to file another... if only I could!


Anyway, if someone else is luckier, here what I'd have liked to file:

PHP version: 5.3.8
Package affected: Compile issues/Compilation warning
Bug type: Feature/Change request
OS: All (seen under Linux)
Summary: char* field should be const char* to avoid C++ warning
Description:
http://news.php.net/php.internals/55662

I'm writing a C++ extension to PHP.
When declaring a INI entry I get the following warning, multiple times:
warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

This only arises when compiling with a C++ compiler.
The right and easy fix seems to set some fields to const char *.
Some may even be set to const char * const (but this alternative seems
to be used
nowhere).

The proposed patch is against the php5-dev-5.3.8-2 package of debian sid:
PHP 5.3.8-2 with Suhosin-Patch (cli) (built: Sep 12 2011 07:28:26)
- - -
Test script:
Write a C++ extension:
config.m4 should contain PHP_REQUIRE_CXX().

Declare your module:
zend_module_entry quezako_module_entry = {
    STANDARD_MODULE_HEADER,
    "YourExtensionName", // (1 warning here)
    [...],
    "0.42", // (1 warning here)
    [...],
    STANDARD_MODULE_PROPERTIES_EX
};

Declare an INI entry:
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY(
    "extensionName.variable", // (1 warning here)
    "default value", // (1 warning here)
    [...]
)
PHP_INI_END()
- - -
Patch name: field_constness_cpp_compilation_warning_fix.patch
Patch file: (see attached file)
Expected result:
No compilation warning.
- - -
Actual result:
Multiple of the following warning:
warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Using the very common fix of prepending (char*) to the string constant is
especially harmful here, because of ZEND_INI_ENTRY3_EX using sizeof() on in: it
returns 4/8 (32/64bits platform).
Using a cast to char[] solves the problem, but the above fix is a very very
common mistake.

If the target fields were const char*, no compilation warning would be rose.
- - -
Solve the problem 17 + 23 = ?: 40 (I even checked the answer using a
calculator!!!!)
Submit: Send bug report (I'm going mad, really...)

--
Olivier Favre
Software engineer
Yakaz
www.yakaz.com
--- zend_ini.h	2011-09-30 10:18:59.630952034 +0200
+++ /usr/include/php5/Zend/zend_ini.h	2011-09-29 12:24:39.012882527 +0200
@@ -65,14 +65,14 @@
 struct _zend_ini_entry {
 	int module_number;
 	int modifiable;
-	const char *name;
+	char *name;
 	uint name_length;
 	ZEND_INI_MH((*on_modify));
 	void *mh_arg1;
 	void *mh_arg2;
 	void *mh_arg3;
 
-	const char *value;
+	char *value;
 	uint value_length;
 
 	char *orig_value;
--- zend_modules.h	2011-09-30 10:19:54.234949674 +0200
+++ /usr/include/php5/Zend/zend_modules.h	2011-09-12 09:44:01.000000000 +0200
@@ -98,7 +98,7 @@
 	unsigned char type;
 	void *handle;
 	int module_number;
-	const char *build_id;
+	char *build_id;
 };
 
 #define MODULE_DEP_REQUIRED		1
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to