Message ID | 96e57488-2dba-f4f1-4215-9ee3f259bb3a@suse.cz |
---|---|
State | Committed |
Commit | c5c523723149112d117a6d3b259dfd95b032a545 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9896A3857365 for <patchwork@sourceware.org>; Mon, 16 May 2022 08:38:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 6E9CE385780C for <gcc-patches@gcc.gnu.org>; Mon, 16 May 2022 08:37:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E9CE385780C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 498AE21F11 for <gcc-patches@gcc.gnu.org>; Mon, 16 May 2022 08:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1652690276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ky+geamkRGz+9lROwA8Qh+TzPRWagV4/y5Mqd5yipGM=; b=wzI0MWgC55AB/95c7wIb7G8UEBwbYx/darsQ4U2e/iUER1pvC7CNHxhAnwEc6D1ME9XFqd sPzXoIOCwLxv8Qb2WpcvZsPttN++MsFs6GXjCi816uCu+4JL3us1j7RpxnXv27nlKfrQax LDSghKKUNlsu1416VYj4ZgKquccjsrw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1652690276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ky+geamkRGz+9lROwA8Qh+TzPRWagV4/y5Mqd5yipGM=; b=MkGnW0AGnZIa5RWUeHEDPcmxDMVO2cOCdVsmO0sCrDaWO0Q8RemAasw4W6X88iZu1gwv43 p5mYX22AyMK7PABg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3B88B13ADC for <gcc-patches@gcc.gnu.org>; Mon, 16 May 2022 08:37:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id i9uRDGQNgmIhcgAAMHmgww (envelope-from <mliska@suse.cz>) for <gcc-patches@gcc.gnu.org>; Mon, 16 May 2022 08:37:56 +0000 Message-ID: <96e57488-2dba-f4f1-4215-9ee3f259bb3a@suse.cz> Date: Mon, 16 May 2022 10:37:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= <mliska@suse.cz> Subject: [PATCH] Mitigate -Wmaybe-uninitialized in expmed.cc. To: gcc-patches@gcc.gnu.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
Mitigate -Wmaybe-uninitialized in expmed.cc.
|
|
Commit Message
Martin Liška
May 16, 2022, 8:37 a.m. UTC
It's the warning I see every time I build GCC: In file included from /home/marxin/Programming/gcc/gcc/coretypes.h:478, from /home/marxin/Programming/gcc/gcc/expmed.cc:26: In function ‘poly_uint16 mode_to_bytes(machine_mode)’, inlined from ‘typename if_nonpoly<typename T::measurement_type>::type GET_MODE_SIZE(const T&) [with T = scalar_int_mode]’ at /home/marxin/Programming/gcc/gcc/machmode.h:647:24, inlined from ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’ at /home/marxin/Programming/gcc/gcc/expmed.cc:5728:56: /home/marxin/Programming/gcc/gcc/machmode.h:550:49: warning: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized] 550 | ? mode_size_inline (mode) : mode_size[mode]); | ^~~~ /home/marxin/Programming/gcc/gcc/expmed.cc: In function ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’: /home/marxin/Programming/gcc/gcc/expmed.cc:5657:19: note: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here 5657 | scalar_int_mode int_mode; | ^~~~~~~~ Can we please mitigate it? gcc/ChangeLog: * expmed.cc (emit_store_flag_1): Mitigate -Wmaybe-uninitialized warning. --- gcc/expmed.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Martin Liška <mliska@suse.cz> writes: > It's the warning I see every time I build GCC: > > In file included from /home/marxin/Programming/gcc/gcc/coretypes.h:478, > from /home/marxin/Programming/gcc/gcc/expmed.cc:26: > In function ‘poly_uint16 mode_to_bytes(machine_mode)’, > inlined from ‘typename if_nonpoly<typename T::measurement_type>::type GET_MODE_SIZE(const T&) [with T = scalar_int_mode]’ at /home/marxin/Programming/gcc/gcc/machmode.h:647:24, > inlined from ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’ at /home/marxin/Programming/gcc/gcc/expmed.cc:5728:56: > /home/marxin/Programming/gcc/gcc/machmode.h:550:49: warning: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized] > 550 | ? mode_size_inline (mode) : mode_size[mode]); > | ^~~~ > /home/marxin/Programming/gcc/gcc/expmed.cc: In function ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’: > /home/marxin/Programming/gcc/gcc/expmed.cc:5657:19: note: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here > 5657 | scalar_int_mode int_mode; > | ^~~~~~~~ > > Can we please mitigate it? > > gcc/ChangeLog: > > * expmed.cc (emit_store_flag_1): Mitigate -Wmaybe-uninitialized > warning. Not a strong objection, but TBH I'd rather we didn't work around false positives like this. Richard > --- > gcc/expmed.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/expmed.cc b/gcc/expmed.cc > index 41738c1efe9..f23d63471ea 100644 > --- a/gcc/expmed.cc > +++ b/gcc/expmed.cc > @@ -5654,7 +5654,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, > > /* If we are comparing a double-word integer with zero or -1, we can > convert the comparison into one involving a single word. */ > - scalar_int_mode int_mode; > + scalar_int_mode int_mode = {}; > if (is_int_mode (mode, &int_mode) > && GET_MODE_BITSIZE (int_mode) == BITS_PER_WORD * 2 > && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0)))
On Mon, May 16, 2022 at 11:18 AM Richard Sandiford via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Martin Liška <mliska@suse.cz> writes: > > It's the warning I see every time I build GCC: > > > > In file included from /home/marxin/Programming/gcc/gcc/coretypes.h:478, > > from /home/marxin/Programming/gcc/gcc/expmed.cc:26: > > In function ‘poly_uint16 mode_to_bytes(machine_mode)’, > > inlined from ‘typename if_nonpoly<typename T::measurement_type>::type GET_MODE_SIZE(const T&) [with T = scalar_int_mode]’ at /home/marxin/Programming/gcc/gcc/machmode.h:647:24, > > inlined from ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’ at /home/marxin/Programming/gcc/gcc/expmed.cc:5728:56: > > /home/marxin/Programming/gcc/gcc/machmode.h:550:49: warning: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized] > > 550 | ? mode_size_inline (mode) : mode_size[mode]); > > | ^~~~ > > /home/marxin/Programming/gcc/gcc/expmed.cc: In function ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’: > > /home/marxin/Programming/gcc/gcc/expmed.cc:5657:19: note: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here > > 5657 | scalar_int_mode int_mode; > > | ^~~~~~~~ > > > > Can we please mitigate it? > > > > gcc/ChangeLog: > > > > * expmed.cc (emit_store_flag_1): Mitigate -Wmaybe-uninitialized > > warning. > > Not a strong objection, but TBH I'd rather we didn't work around false > positives like this. It only seems to happen with your host compiler though? The set of # These files are to have specific diagnostics suppressed, or are not to # be subject to -Werror: # flex output may yield harmless "no previous prototype" warnings build/gengtype-lex.o-warn = -Wno-error gengtype-lex.o-warn = -Wno-error libgcov-util.o-warn = -Wno-error libgcov-driver-tool.o-warn = -Wno-error libgcov-merge-tool.o-warn = -Wno-error gimple-match.o-warn = -Wno-unused generic-match.o-warn = -Wno-unused dfp.o-warn = -Wno-strict-aliasing doesn't include expmed.o at least. > Richard > > > --- > > gcc/expmed.cc | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/gcc/expmed.cc b/gcc/expmed.cc > > index 41738c1efe9..f23d63471ea 100644 > > --- a/gcc/expmed.cc > > +++ b/gcc/expmed.cc > > @@ -5654,7 +5654,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, > > > > /* If we are comparing a double-word integer with zero or -1, we can > > convert the comparison into one involving a single word. */ > > - scalar_int_mode int_mode; > > + scalar_int_mode int_mode = {}; > > if (is_int_mode (mode, &int_mode) > > && GET_MODE_BITSIZE (int_mode) == BITS_PER_WORD * 2 > > && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0)))
On 5/16/22 12:32, Richard Biener wrote:
> It only seems to happen with your host compiler though? The set of
Yes, happens with just released 12.1 as host compiler:
g++ -fcf-protection -fno-PIE -c -g -O2 -DIN_GCC -fPIC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -I. -I/home/marxin/Programming/gcc/gcc -I/home/marxin/Programming/gcc/gcc/. -I/home/marxin/Programming/gcc/gcc/../include -I/home/marxin/Programming/gcc/gcc/../libcpp/include -I/home/marxin/Programming/gcc/gcc/../libcody -I/home/marxin/Programming/gcc/gcc/../libdecnumber -I/home/marxin/Programming/gcc/gcc/../libdecnumber/bid -I../libdecnumber -I/home/marxin/Programming/gcc/gcc/../libbacktrace -o expmed.o -MT expmed.o -MMD -MP -MF ./.deps/expmed.TPo /home/marxin/Programming/gcc/gcc/expmed.cc
In file included from /home/marxin/Programming/gcc/gcc/coretypes.h:478,
from /home/marxin/Programming/gcc/gcc/expmed.cc:26:
In function ‘poly_uint16 mode_to_bytes(machine_mode)’,
inlined from ‘typename if_nonpoly<typename T::measurement_type>::type GET_MODE_SIZE(const T&) [with T = scalar_int_mode]’ at /home/marxin/Programming/gcc/gcc/machmode.h:647:24,
inlined from ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’ at /home/marxin/Programming/gcc/gcc/expmed.cc:5728:56:
/home/marxin/Programming/gcc/gcc/machmode.h:550:49: warning: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized]
550 | ? mode_size_inline (mode) : mode_size[mode]);
| ^~~~
/home/marxin/Programming/gcc/gcc/expmed.cc: In function ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’:
/home/marxin/Programming/gcc/gcc/expmed.cc:5657:19: note: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here
5657 | scalar_int_mode int_mode;
| ^~~~~~~~
Cheers,
Martin
On 5/16/22 10:56, Richard Sandiford wrote: > Martin Liška <mliska@suse.cz> writes: >> It's the warning I see every time I build GCC: >> >> In file included from /home/marxin/Programming/gcc/gcc/coretypes.h:478, >> from /home/marxin/Programming/gcc/gcc/expmed.cc:26: >> In function ‘poly_uint16 mode_to_bytes(machine_mode)’, >> inlined from ‘typename if_nonpoly<typename T::measurement_type>::type GET_MODE_SIZE(const T&) [with T = scalar_int_mode]’ at /home/marxin/Programming/gcc/gcc/machmode.h:647:24, >> inlined from ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’ at /home/marxin/Programming/gcc/gcc/expmed.cc:5728:56: >> /home/marxin/Programming/gcc/gcc/machmode.h:550:49: warning: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized] >> 550 | ? mode_size_inline (mode) : mode_size[mode]); >> | ^~~~ >> /home/marxin/Programming/gcc/gcc/expmed.cc: In function ‘rtx_def* emit_store_flag_1(rtx, rtx_code, rtx, rtx, machine_mode, int, int, machine_mode)’: >> /home/marxin/Programming/gcc/gcc/expmed.cc:5657:19: note: ‘*(unsigned int*)((char*)&int_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here >> 5657 | scalar_int_mode int_mode; >> | ^~~~~~~~ >> >> Can we please mitigate it? >> >> gcc/ChangeLog: >> >> * expmed.cc (emit_store_flag_1): Mitigate -Wmaybe-uninitialized >> warning. > > Not a strong objection, but TBH I'd rather we didn't work around false > positives like this. Sure, but as you know, -Wmaybe-uninitialized has pretty high rate of false positivity :/ Martin > > Richard > >> --- >> gcc/expmed.cc | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/gcc/expmed.cc b/gcc/expmed.cc >> index 41738c1efe9..f23d63471ea 100644 >> --- a/gcc/expmed.cc >> +++ b/gcc/expmed.cc >> @@ -5654,7 +5654,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, >> >> /* If we are comparing a double-word integer with zero or -1, we can >> convert the comparison into one involving a single word. */ >> - scalar_int_mode int_mode; >> + scalar_int_mode int_mode = {}; >> if (is_int_mode (mode, &int_mode) >> && GET_MODE_BITSIZE (int_mode) == BITS_PER_WORD * 2 >> && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0)))
diff --git a/gcc/expmed.cc b/gcc/expmed.cc index 41738c1efe9..f23d63471ea 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -5654,7 +5654,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, /* If we are comparing a double-word integer with zero or -1, we can convert the comparison into one involving a single word. */ - scalar_int_mode int_mode; + scalar_int_mode int_mode = {}; if (is_int_mode (mode, &int_mode) && GET_MODE_BITSIZE (int_mode) == BITS_PER_WORD * 2 && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0)))