From patchwork Tue Nov 18 20:53:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 3797 Received: (qmail 30485 invoked by alias); 18 Nov 2014 20:53:15 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 30474 invoked by uid 89); 18 Nov 2014 20:53:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.cs.ucla.edu Message-ID: <546BB1B1.50000@cs.ucla.edu> Date: Tue, 18 Nov 2014 12:53:05 -0800 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Joseph Myers , libc-alpha@sourceware.org Subject: Re: Add macros for diagnostic control, use them in locale/weightwc.h References: In-Reply-To: On 11/18/2014 10:04 AM, Joseph Myers wrote: > + DIAG_PUSH; > +#if __GNUC_PREREQ (4, 7) > + DIAG_IGNORE (-Wmaybe-uninitialized, 4.9); > +#endif > if (cp[nhere - 1] > usrc[nhere -1]) > { > cp += 2 * nhere; > @@ -105,6 +117,7 @@ findidx (const int32_t *table, > /* This range matches the next characters. Now find > the offset in the indirect table. */ > offset = usrc[nhere - 1] - cp[nhere - 1]; > + DIAG_POP; My kneejerk reaction is that attempting to minimize the scope of disabled warnings will make code harder to read and maintain, and the costs of minimization may outweigh the benefits. Also, the distinction between GCC version "4, 7" (which is checked) and version "4.9" (which is not) is bothersome. Inevitably the unchecked version numbers will become wrong. If we're going to have a "4.9" at all, we should check it. How about the attached (untested) patch instead? This is simpler and less intrusive and should scale better. It disables the diagnostic in some places that it doesn't absolutely need to, but it separates concerns better and overall I expect it would have a better cost-to-benefit ratio. diff --git a/ChangeLog b/ChangeLog index 37b1459..ab9dc88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-11-18 Paul Eggert + + * locale/weightwc.h (findidx): Disable -Wmaybe-uninitialized. + 2014-11-18 Roland McGrath * nptl/createthread.c: New file. diff --git a/locale/weightwc.h b/locale/weightwc.h index 0f70b00..383d34e 100644 --- a/locale/weightwc.h +++ b/locale/weightwc.h @@ -19,6 +19,14 @@ #ifndef _WEIGHTWC_H_ #define _WEIGHTWC_H_ 1 +#pragma GCC diagnostic push + +/* Seen on x86_64 (inlined from fnmatch_loop.c:internal_fnwmatch): + "'*((void *)&str+4)' may be used uninitialized in this function". */ +#if __GNUC_PREREQ (4, 7) && !__GNUC_PREPREQ (4, 10) +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + /* Find index of weight. */ static inline int32_t __attribute__ ((always_inline)) findidx (const int32_t *table, @@ -115,4 +123,6 @@ findidx (const int32_t *table, return 0x43219876; } +#pragma GCC diagnostic pop + #endif /* weightwc.h */