public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: "Martin Liška" <mliska@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Mitigate -Wmaybe-uninitialized in expmed.cc.
Date: Mon, 16 May 2022 09:56:20 +0100	[thread overview]
Message-ID: <mpth75p26vf.fsf@arm.com> (raw)
In-Reply-To: <96e57488-2dba-f4f1-4215-9ee3f259bb3a@suse.cz> ("Martin \=\?utf-8\?Q\?Li\=C5\=A1ka\=22's\?\= message of "Mon, 16 May 2022 10:37:55 +0200")

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)))

  reply	other threads:[~2022-05-16  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16  8:37 Martin Liška
2022-05-16  8:56 ` Richard Sandiford [this message]
2022-05-16 10:32   ` Richard Biener
2022-05-17 14:35     ` Martin Liška
2022-05-19 14:17   ` Martin Liška

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpth75p26vf.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).