From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id D5B353839DD5 for ; Sun, 23 Oct 2022 16:34:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D5B353839DD5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 8003F340CCF; Sun, 23 Oct 2022 16:34:18 +0000 (UTC) Date: Sun, 23 Oct 2022 21:04:52 +0545 From: Mike Frysinger To: Tsukasa OI Cc: Andrew Burgess , Nick Clifton , gdb-patches@sourceware.org Subject: Re: [PATCH 35/40] sim/sh: Initialize some variables Message-ID: Mail-Followup-To: Tsukasa OI , Andrew Burgess , Nick Clifton , gdb-patches@sourceware.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OXzYb1yMBJg7qG57" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --OXzYb1yMBJg7qG57 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 20 Oct 2022 09:32, Tsukasa OI wrote: > Clang generates a warning if a variable may be used uninitialized on some > cases ("-Wsometimes-uninitialized"). On the default configuration, it > causes a build failure (unless "--disable-werror" is specified). >=20 > The cause of this error, $(builddir)/sim/sh/ppi.c is generated from > $(srcdir)/sim/sh/gencode.c. Clang will detect the variable res may be us= ed > uninitialized when used on some cases. >=20 > Likewise, GCC generates a warning if a variable may be used uninitialized > on some cases ("-Wmaybe-uninitialized"). >=20 > GCC will detect variables res, res_grd, carry, overflow and greater_equal > may be used uninitialized on some cases. Despite that GCC will not cause= a > build failure even when "--enable-werror" is specified, it would be better > to fix this as well since the cause is in the same function. > --- > sim/sh/gencode.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > --- a/sim/sh/gencode.c > +++ b/sim/sh/gencode.c > @@ -3257,8 +3257,8 @@ ppi_gensim (void) > printf (" static char const u_tab[] =3D { 8, 10, 7, 5};\n"); > printf ("\n"); > printf (" int z;\n"); > - printf (" int res, res_grd;\n"); > - printf (" int carry, overflow, greater_equal;\n"); > + printf (" int res =3D 0, res_grd =3D 0;\n"); > + printf (" int carry =3D 0, overflow =3D 0, greater_equal =3D 0;\n"); i've left this warning in because i don't know what the right answer is, and i'm not inclined to dig into the ISA to find out. simply initializing the variables to 0 might mean we're masking real bugs where we should be loading the state from the current CPU registers instead. -mike --OXzYb1yMBJg7qG57 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmNVW5gACgkQQWM7n+g3 9YHRIRAAjPZ37pdZWWQ4u+gTJ7vMvnjtnrjTA4GNrHEgjy+lS7jVGkeyWkG913Fz Qmxum3eloWhqRnwoaR77D8ru6Da+cJeURLQTG2sG+9cZRNg9KmrR32EhQDolJ+Uk z4EStS9FtXUDS1FN+p2jHlTDpg3tX41D7chalcmJuY+cotxadjLAQrAlz/2tfyMx I+oosSxVVTHKYlCeYHVeS/aBLXszpF5eg3YfVh9rMKXZT22Co5ndqQrPU2s4WVpp Bsh7hMpXpuPVYH3ycIJO5BevbgJeOmnLP+lDTa4604A6EX5ZwtOSwG780AxZ1jmQ uOeNC0MD88yvYEb6BvLGNlRaACTQurhUfNOC+TDSLszXLCekxtZ36CZjnYyg+bQR OlnmQn/s1O5uArPTiBiS+VGHkTq2/CPi7fpze7nRtkMg8ZSH7LNzM+Qw29UCFxkM hZd+BtWbU36INJyPG2ft+neAs8xwC8khgKiUVugfJZTTVtOZw0P8EzFCcnETQ3JG aoWFtmQUkffc1l3nfxm3UUn78voVqEV2b7Z3ohwxSfFOgg8ucZy2EPZ3iis6n+27 gdN6ysw2YEgl5mMYJhi3DD9g7cHNxLnphWZ7t+h7Qhl6gRr0MzLjfTw/i3w41vAJ 3xKc1n/4rTmE2bMF6Rp/XUFYj+DX6BqTtBm9L8f3qXeDPAreIPE= =BQde -----END PGP SIGNATURE----- --OXzYb1yMBJg7qG57--