Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A3B6EB5DC1B for ; Tue, 20 Sep 2011 20:29:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 88568-05 for ; Tue, 20 Sep 2011 23:29:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com [209.85.216.174]) by mail.postgresql.org (Postfix) with ESMTP id 0A6E1B5DC13 for ; Tue, 20 Sep 2011 20:29:30 -0300 (ADT) Received: by qyk30 with SMTP id 30so4473465qyk.19 for ; Tue, 20 Sep 2011 16:29:30 -0700 (PDT) Received: by 10.52.67.12 with SMTP id j12mr1289063vdt.30.1316561370242; Tue, 20 Sep 2011 16:29:30 -0700 (PDT) Received: from [10.1.1.6] (124-148-242-247.dyn.iinet.net.au. [124.148.242.247]) by mx.google.com with ESMTPS id l4sm2302601vdv.4.2011.09.20.16.29.27 (version=SSLv3 cipher=OTHER); Tue, 20 Sep 2011 16:29:29 -0700 (PDT) Message-ID: <4E7921D3.7030209@ringerc.id.au> Date: Wed, 21 Sep 2011 07:29:23 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: Lionel Elie Mamane CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6216: Calling PQconnectdbParams from C++ with a char** References: <201109201605.p8KG5tku049175@wwwmaster.postgresql.org> In-Reply-To: <201109201605.p8KG5tku049175@wwwmaster.postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/131 X-Sequence-Number: 31148 On 21/09/2011 12:05 AM, Lionel Elie Mamane wrote: > The following bug has been logged online: > > Bug reference: 6216 > Logged by: Lionel Elie Mamane > Email address: lionel@mamane.lu > PostgreSQL version: 9.1.0 > Operating system: Debian GNU/Linux > Description: Calling PQconnectdbParams from C++ with a char** > Details: > > In C++, a "char**" value is not convertible to a "const char**" value, > because that is not safe (see > http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.17). > > This means one cannot call libpq's PQconnectdbParams and friends passing > them a "char**" value for keywords and/or values, as these arguments are > declared "const char**". > > So please apply this patch, which declares them "char const* const*" > instead, which is: > - equivalent to "const char * const*"; use that one if you prefer Yeah, this really annoyed me when I was working with C libraries from C++. +1 from me; this should be applied. Lionel: Can I get you to add the patch to the commitfest app? https://commitfest.postgresql.org/ I'll accept review of it once you do and flag it as ready for committer so we can streamline its inclusion. As for wording: my *personal* preference is "const char * const" but I don't know what the opinions of those who work with the code day-to-day are. -- Craig Ringer