Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55690 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42791 invoked from network); 3 Oct 2011 08:02:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2011 08:02:09 -0000 Authentication-Results: pb1.pair.com header.from=olivier@yakaz.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=olivier@yakaz.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain yakaz.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: olivier@yakaz.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:45866] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/A1-32319-FFB698E4 for ; Mon, 03 Oct 2011 04:02:09 -0400 Received: by qyl16 with SMTP id 16so1818841qyl.8 for ; Mon, 03 Oct 2011 01:02:05 -0700 (PDT) Received: by 10.229.82.76 with SMTP id a12mr7436674qcl.110.1317628925154; Mon, 03 Oct 2011 01:02:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.190.199 with HTTP; Mon, 3 Oct 2011 01:01:45 -0700 (PDT) In-Reply-To: References: <4E848B31.2030501@gmail.com> <4E84A73E.8030601@gmail.com> <4E84B4DE.3070904@hristov.com> <4E84D3DE.8010805@gmail.com> Date: Mon, 3 Oct 2011 10:01:45 +0200 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Cast trap with INI entries compiling C++ extension From: olivier@yakaz.com (Olivier Favre) I finally managed to submit the patch... I used iceweasel 6.0.2 instead of Google Chrome=C2=A014.0.835.186... or maybe the captcha was just in a better mood! The link to the bug report:=C2=A0https://bugs.php.net/bug.php?id=3D55835 Yours, -- Olivier Favre Software engineer Yakaz www.yakaz.com 2011/9/30 Olivier Favre > > I keep on having the following error: > =C2=A0 =C2=A0ERROR: > =C2=A0 =C2=A0=E2=8B=85 Incorrect Captcha > while trying to file a bug on the following page: > =C2=A0 =C2=A0https://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: > =C2=A0- https://bugs.php.net/bug.php?id=3D54380 > =C2=A0- https://bugs.php.net/bug.php?id=3D53255 > 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-s= trings] > > 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 =3D { > =C2=A0 =C2=A0STANDARD_MODULE_HEADER, > =C2=A0 =C2=A0"YourExtensionName", // (1 warning here) > =C2=A0 =C2=A0[...], > =C2=A0 =C2=A0"0.42", // (1 warning here) > =C2=A0 =C2=A0[...], > =C2=A0 =C2=A0STANDARD_MODULE_PROPERTIES_EX > }; > > Declare an INI entry: > PHP_INI_BEGIN() > STD_PHP_INI_ENTRY( > =C2=A0 =C2=A0"extensionName.variable", // (1 warning here) > =C2=A0 =C2=A0"default value", // (1 warning here) > =C2=A0 =C2=A0[...] > ) > 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-s= trings] > > 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 ve= ry > common mistake. > > If the target fields were const char*, no compilation warning would be ro= se. > - - - > Solve the problem 17 + 23 =3D ?: 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