From patchwork Sat Mar 10 20:36:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 884161 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-90965-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=panix.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="c9RCCtBS"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zzGHl3lLBzB2b3 for ; Sun, 11 Mar 2018 07:36:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=vmsmdrRUfSzPKGfN EoL8JKYWl++a9cCWRrCRahE43SDafFV3d2+p0P5/fkhj0z6cQUYTExr1v0plvBJd rrHjbw9PpqFMNoyl50Qi31NPhgmTeObqluM+Eim+FF8NGv1hNksdibwkxEqs2jaS A3ob+VawIfxd3WizjRy68O5SQ7k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=AA/uupHOoHi85bG6+6Hoz+ /25jU=; b=c9RCCtBSdW6p1sbsg8C+gxX7CrOAecu2X4NO6/c6wTv05Pa1nOzseb Wzzc+tJFJoispZ1u1gZFkyX4Mwi6eu8+m8BqhLxehHf2d4ph06nmweT9PFuDD69L CyIKF02nQhXr1KNIqRr5WHUgFEqoJb1xDzPCo3cSpUCkMmdkE842c= Received: (qmail 44229 invoked by alias); 10 Mar 2018 20:36:29 -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 44219 invoked by uid 89); 10 Mar 2018 20:36:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=8347 X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Subject: [RFC PATCH] Disable uninitialized warnings around va_arg(, long double) Date: Sat, 10 Mar 2018 15:36:25 -0500 Message-Id: <20180310203625.13515-1-zackw@panix.com> MIME-Version: 1.0 This is the only nontrivial problem I found in build-many-glibcs testing of my "use more flags parameters instead of global bits in stdio" patchset. My changes to vfprintf in that patchset tickle a bug in the PowerPC-SPE back end, leading to spurious "used uninitialized" warnings--not on any code we control, but on a scratch variable emitted as part of the expansion of __builtin_va_arg! This is , Jakub already has a fix in hand, and I'm not sure whether it's worth bothering to include these DIAG_IGNOREs in our tree. I suppose it depends on whether the bug manifests in compilers older than 7.3 as well. * stdio-common/vfprintf-internal.c: Include libc-diag.h. Disable -Wuninitialized and -Wmaybe-uninitialized around all uses of va_arg(..., long double), to work around GCC bug 84772. --- stdio-common/vfprintf-internal.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index d8716f4f07..6f7bd0d2da 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -31,6 +31,7 @@ #include #include #include +#include /* This code is shared between the standard stdio implementation found in GNU C library and the libio implementation originally found in @@ -774,9 +775,19 @@ static const uint8_t jump_table[] = .is_binary128 = 0}; \ \ if (is_long_double) \ - the_arg.pa_long_double = va_arg (ap, long double); \ + { \ + /* GCC 7.3 has a bug on some architectures where */ \ + /* va_arg (ap, long double) produces spurious warnings. */ \ + /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84772 */ \ + DIAG_PUSH_NEEDS_COMMENT; \ + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wuninitialized"); \ + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wmaybe-uninitialized"); \ + the_arg.pa_long_double = va_arg (ap, long double); \ + DIAG_POP_NEEDS_COMMENT; \ + } \ else \ the_arg.pa_double = va_arg (ap, double); \ + \ ptr = (const void *) &the_arg; \ \ function_done = __printf_fp (s, &info, &ptr); \ @@ -834,7 +845,16 @@ static const uint8_t jump_table[] = .is_binary128 = 0}; \ \ if (is_long_double) \ - the_arg.pa_long_double = va_arg (ap, long double); \ + { \ + /* GCC 7.3 has a bug on some architectures where */ \ + /* va_arg (ap, long double) produces spurious warnings. */ \ + /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84772 */ \ + DIAG_PUSH_NEEDS_COMMENT; \ + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wuninitialized"); \ + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wmaybe-uninitialized"); \ + the_arg.pa_long_double = va_arg (ap, long double); \ + DIAG_POP_NEEDS_COMMENT; \ + } \ else \ the_arg.pa_double = va_arg (ap, double); \ ptr = (const void *) &the_arg; \ @@ -844,7 +864,7 @@ static const uint8_t jump_table[] = else \ { \ ptr = (const void *) &args_value[fspec->data_arg]; \ - if (LDBL_IS_DBL) \ + if (LDBL_IS_DBL) \ fspec->info.is_long_double = 0; \ /* Not supported by *printf functions. */ \ fspec->info.is_binary128 = 0; \ @@ -1878,7 +1898,16 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format, args_type[cnt] &= ~PA_FLAG_LONG_DOUBLE; } else - args_value[cnt].pa_long_double = va_arg (*ap_savep, long double); + { + /* GCC 7.3 has a bug on some architectures where + va_arg (ap, long double) produces spurious warnings. + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84772 */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wuninitialized"); + DIAG_IGNORE_NEEDS_COMMENT (7.3, "-Wmaybe-uninitialized"); + args_value[cnt].pa_long_double = va_arg (*ap_savep, long double); + DIAG_POP_NEEDS_COMMENT; + } break; case PA_STRING: /* All pointers are the same */ case PA_WSTRING: /* All pointers are the same */