From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36776 invoked by alias); 29 Oct 2016 03:03:30 -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 36761 invoked by uid 89); 29 Oct 2016 03:03:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=eggert, Eggert, wish, reader X-HELO: mx1.redhat.com Subject: Re: [PATCH] Fix -Os related -Werror failures. To: Paul Eggert , Arnd Bergmann , libc-alpha@sourceware.org References: <6eac682f-26fa-6a47-9497-357206266ba1@redhat.com> <6be7dce5-bfa7-32c7-5bac-6c3b79776683@redhat.com> <9d58289e-07fb-4bae-d7d3-8055a6c96a3a@redhat.com> <20863164.XNWC5rYB1g@wuerfel> <7820c555-1463-6c3a-17e5-650a44fabd19@cs.ucla.edu> Cc: Florian Weimer , "Carlos O'Donell" From: Jeff Law Message-ID: <6a3047c8-8d7c-f89a-222b-5fea7c743022@redhat.com> Date: Sat, 29 Oct 2016 03:03: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: <7820c555-1463-6c3a-17e5-650a44fabd19@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-10/txt/msg00581.txt.bz2 On 10/28/2016 02:10 PM, Paul Eggert wrote: > On 10/28/2016 01:12 AM, Arnd Bergmann wrote: >> I found that most often when gcc is confused about whether a variable >> is uninitialized or not, the source code tends to be confusing to a >> human reader as well and rewriting it differently results in better >> readability and better object code while avoiding the warning. > > I'm afraid my experience has not been so good. Maybe 1/3 of the time > rewriting is better, but otherwise rewriting doesn't help or even > confuses the code. When that happens with -Wmaybe-uninitialized, in > Emacs we typically use C declarations like this: > > ptrdiff_t offset2 UNINIT; /* The UNINIT works around GCC bug > 78081. */ And I would echo that markup indicating that the initializer is to work around a GCC false positive is something I wish we had strictly enforced within GCC itself when it was made Wuninitialized clean. GCC has made significant strides in its jump threading and predicate analysis to significantly such false positives and many of these initializers could probably be removed at this point. > > where UNINIT is defined something like this: > > #ifdef GCC_LINT > # define UNINIT = {0,} > #else > # define UNINIT /* empty */ > #endif > > and configuring with --enable-gcc-warnings compiles with something like > 'gcc -Wall -Werror -DGCC_LINT'.\ But I would caution against blindly using 0 as an initializer. Each case has to be examined to determine what a safe value would be. Often 0 is appropriate, but there are certainly cases where it is not the safe initializer to use. Jeff