From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39808 invoked by alias); 28 Oct 2016 06:44:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 39799 invoked by uid 89); 28 Oct 2016 06:44:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=indicator, hides, recommendation, assured X-HELO: mx1.redhat.com Subject: Re: [PATCH] Fix -Os related -Werror failures. To: Florian Weimer , "Carlos O'Donell" , GNU C Library References: <6eac682f-26fa-6a47-9497-357206266ba1@redhat.com> <6be7dce5-bfa7-32c7-5bac-6c3b79776683@redhat.com> From: Jeff Law Message-ID: <9d58289e-07fb-4bae-d7d3-8055a6c96a3a@redhat.com> Date: Fri, 28 Oct 2016 06:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <6be7dce5-bfa7-32c7-5bac-6c3b79776683@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-10/txt/msg00510.txt.bz2 On 10/28/2016 12:32 AM, Florian Weimer wrote: > On 10/28/2016 06:46 AM, Carlos O'Donell wrote: >> +/* With GCC 5.3 when compiling with -Os the compiler emits a warning >> + that buf[0] and buf[1] may be used uninitialized. This can only >> + happen in the case where tmpbuf[3] is used, and in that case the >> + write to the tmpbuf[1] and tmpbuf[2] was assured because >> + ucs4_to_cns11643 would have filled in those entries. The difficulty >> + is in getting the compiler to see this logic because tmpbuf[0] is >> + involved in determining the code page and is the indicator that >> + tmpbuf[2] is initialized. */ >> +DIAG_PUSH_NEEDS_COMMENT; >> +DIAG_IGNORE_NEEDS_COMMENT (5.3, "-Wmaybe-uninitialized"); > > This hides the warning for -O2 builds as well, so I don't think this is > a good idea. > > Those who want to build with -Os or other special compiler flags should > just configure with --disable-werror. We can't account for every > optimization someone might want to disable in their build. That'd be my recommendation. What often happens in these cases is the compiler in its default mode of operation is able to statically eliminate a conditional branch on a particular path. However, to do so the compiler has to duplicate code. Not surprisingly, there's a cost/benefit tradeoff here and the heuristics are largely driven by the real or estimated profile data as well as the coarser "optimize for code space". So changing flags changes the output of those heuristics and ultimately can result in leaving paths in the CFG that can not be executed -- and that often leads to false positive may-be-uninitialized warnings and such. Long term I would like to find a good way to mark paths that are not executable, but are not profitable to eliminate, then utilize that information to prune various "may" warnings. That would make those kind of warnings more stable across different optimization levels as well as more stable release-to-release. But that's definitely in the "future work" area. jeff