From patchwork Wed Aug 14 14:49:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 267140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id F17792C0163 for ; Thu, 15 Aug 2013 00:49:43 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=QaiaBILtdclY+tQRvW uBwcnOFVG60A2HdLexqOpsZzvnzWbMnAVijwIMsaT05QlGaVT3FYeXsdAe9fhkDx zW//LwfE99JzAcE1YvUqFM4EIZ4/Kpp/WUr1DwPh6Wn28v1iH/WHMu2lAltmSu0P vuk1OkwAswKTsXUv34nrUcpH8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=L7zSmOQZzG0RTEWSBHTkj4DD o24=; b=XHVFdt23TsJ8/BGpDiO4vEVh1kceIxuL+noW/jL0R9tykZrTIGfozjd1 9ubiIsTLwUV4Ds7OPZMFnhM7+PVmW3sMc5HGi9au65lodJockzwZpmP+BFXJqvQE vl9w/lZ42Itmt52r0cfnqUesU+TGOd9ZMeT15HqRrjOUhu6XEJQ= Received: (qmail 17946 invoked by alias); 14 Aug 2013 14:49:36 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17929 invoked by uid 89); 14 Aug 2013 14:49:36 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients Received: from mail-ob0-f181.google.com (HELO mail-ob0-f181.google.com) (209.85.214.181) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 14 Aug 2013 14:49:08 +0000 Received: by mail-ob0-f181.google.com with SMTP id dn14so11744729obc.26 for ; Wed, 14 Aug 2013 07:49:06 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.101.165 with SMTP id fh5mr7298642obb.58.1376491746733; Wed, 14 Aug 2013 07:49:06 -0700 (PDT) Received: by 10.182.111.167 with HTTP; Wed, 14 Aug 2013 07:49:06 -0700 (PDT) In-Reply-To: References: <5202C08B.7060002@oracle.com> <20130814082909.GM1814@tucnak.redhat.com> Date: Wed, 14 Aug 2013 16:49:06 +0200 Message-ID: Subject: Re: [PATCH, libstdc++]: Avoid -Wcast-qual warnings in src/c++98/compatibility.cc From: Uros Bizjak To: Gabriel Dos Reis Cc: Jakub Jelinek , Paolo Carlini , "gcc-patches@gcc.gnu.org" , "libstdc++" X-Virus-Found: No On Wed, Aug 14, 2013 at 4:36 PM, Uros Bizjak wrote: > On Wed, Aug 14, 2013 at 4:34 PM, Gabriel Dos Reis > wrote: >> On Wed, Aug 14, 2013 at 9:22 AM, Uros Bizjak wrote: >>> >>> On Wed, Aug 14, 2013 at 4:05 PM, Gabriel Dos Reis >>> wrote: >>> > I agree 'const void*' is preferable, and all the places you mention should >>> > be covered too. >>> >>> I already installed my original patch, so attached incremental patch >>> implements preferred solution. >>> >>> 2013-08-14 Uros Bizjak >>> >>> * src/c++98/compatibility.cc (_ZTIe): Use (const cast *) >>> to avoid -Wcast-qual warnings. >>> (_ZTIPe): Ditto. >>> (ZTIPKe): Ditto. >>> >>> Tested on alphaev68-pc-linux-gnu and installed on mainline SVN. >>> >>> Is this solution also OK for other release branches? >>> >>> Uros. >> >> Sorry, when I said 'const void*' was OK, I implicitly assumed that you would >> use C++-style cast reinterpret_cast(_Z….). Same for >> reinterpret_cast(1); > > Ah, OK. I'll add this in a moment. Like the attached patch? Again, build tested on alphaev68-pc-linux-gnu. Uros. Index: src/c++98/compatibility.cc =================================================================== --- src/c++98/compatibility.cc (revision 201727) +++ src/c++98/compatibility.cc (working copy) @@ -517,16 +517,21 @@ extern __attribute__((used, weak)) const char _ZTSPe[3] = "Pe"; extern __attribute__((used, weak)) const char _ZTSPKe[4] = "PKe"; extern __attribute__((used, weak)) const void * const _ZTIe[2] - = { (const void *) &_ZTVN10__cxxabiv123__fundamental_type_infoE[2], - (const void *) _ZTSe }; + = { reinterpret_cast + (&_ZTVN10__cxxabiv123__fundamental_type_infoE[2]), + reinterpret_cast(_ZTSe) }; extern __attribute__((used, weak)) const void * const _ZTIPe[4] - = { (const void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2], - (const void *) _ZTSPe, (const void *) 0L, - (const void *) _ZTIe }; + = { reinterpret_cast + (&_ZTVN10__cxxabiv119__pointer_type_infoE[2]), + reinterpret_cast(_ZTSPe), + reinterpret_cast(0L), + reinterpret_cast(_ZTIe) }; extern __attribute__((used, weak)) const void * const _ZTIPKe[4] - = { (const void *) &_ZTVN10__cxxabiv119__pointer_type_infoE[2], - (const void *) _ZTSPKe, (const void *) 1L, - (const void *) _ZTIe }; + = { reinterpret_cast + (&_ZTVN10__cxxabiv119__pointer_type_infoE[2]), + reinterpret_cast(_ZTSPKe), + reinterpret_cast(1L), + reinterpret_cast(_ZTIe) }; #endif // _GLIBCXX_LONG_DOUBLE_COMPAT #ifdef _GLIBCXX_SYMVER_DARWIN