From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4278 invoked by alias); 22 Jul 2014 17:23:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 4166 invoked by uid 89); 22 Jul 2014 17:23:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,RDNS_DYNAMIC,TVD_RCVD_IP autolearn=no version=3.3.2 X-HELO: brightrain.aerifal.cx Received: from 216-12-86-13.cv.mvl.ntelos.net (HELO brightrain.aerifal.cx) (216.12.86.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Jul 2014 17:23:55 +0000 Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1X9dn1-0002tM-00; Tue, 22 Jul 2014 17:23:47 +0000 Date: Tue, 22 Jul 2014 17:30:00 -0000 From: Rich Felker To: Alexander Monakov Cc: Jan Hubicka , Richard Biener , GCC Patches Subject: Re: [PATCH] proposed fix for bug # 61144 Message-ID: <20140722172347.GX17402@brightrain.aerifal.cx> References: <20140521015948.GA21600@brightrain.aerifal.cx> <20140522035942.GG507@brightrain.aerifal.cx> <20140616085601.GA14894@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-07/txt/msg01476.txt.bz2 On Tue, Jul 22, 2014 at 09:17:12PM +0400, Alexander Monakov wrote: > On Tue, 22 Jul 2014, Alexander Monakov wrote: > > I'd like to push this topic forward a bit. I've bootstrapped and regtested a > > version of the patch based on the initial proposal to check DECL_WEAK. The > > approach with decl_replaceable_p looks not that easy; I'll expand in a > > followup email. > > The problem with the patch below using decl_replaceable_p is that it regresses > the following C++ testcase: > > struct z { > static const int aaa = 1; > }; > > //const int z::aaa; > > int foo(int x) > { > return x ? z::aaa : x; > } > > Here decl_replaceable_p is 'true' for z::aaa. With the patch the reference to > z::aaa is not folded, but its definition is not emitted either, so a undefined > reference error is produced at link time. But naturally > varpool_ctor_useable_for_folding_p for z::aaa must stay true in the first place. > > In a way z::aaa is "replaceable" in the sense that the compiler is not going > to emit a definition, so if anything references z::aaa in the current > translation unit (if the address is taken), the definition must come from > another TU. Nevertheless, references to the value can be folded. I'm > unsure what the correct test would look like. Any advice? Why is this considered "replaceable"? That sounds like a bug to me. Anyway, in looking for a solution, wouldn't it be helpful to look at how this was treated in 4.8 and earlier, before bug 61144 was introduced? Rich