From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 8E5673851C21 for ; Sun, 23 Oct 2022 13:48:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8E5673851C21 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 2D4E9341084; Sun, 23 Oct 2022 13:48:49 +0000 (UTC) Date: Sun, 23 Oct 2022 18:19:23 +0545 From: Mike Frysinger To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 4/5] sim/erc32: avoid dereferencing type-punned pointer warnings Message-ID: Mail-Followup-To: Andrew Burgess , gdb-patches@sourceware.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TcijPd03MczgHlFS" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.2 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: --TcijPd03MczgHlFS Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 12 Oct 2022 13:38, Andrew Burgess via Gdb-patches wrote: > When building the erc32 simulator I get a few warnings like this: >=20 > /tmp/build/sim/../../src/sim/erc32/exec.c:1377:21: warning: dereferenci= ng type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] > 1377 | sregs->fs[rd] =3D *((float32 *) & ddata[0]); > | ~^~~~~~~~~~~~~~~~~~~~~~~ >=20 > The type of '& ddata[0]' will be 'uint32_t *', which is what triggers > the warning. >=20 > This commit uses an intermediate pointer of type 'char *' when > performing the type-punning, which is well-defined behaviour, and will > silence the above warning. this is kind of a poor fix. if we can't arrange for the pointers to be the right type, at least a memcpy would be better. -mike --TcijPd03MczgHlFS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmNVNM8ACgkQQWM7n+g3 9YG1xw//RTQFmE4zVNPyzfZ3TFt2Tk71NxQ4VctDPiKF5Lj5iXxWMDsNEeV4BSU3 GyJTc2PR3Fr1RkfL2t6hiIZnoB3EMjtlf6kNQVuAv8HDbumjuAuO4w2Oe5JmIHUA VcdOAPHWr6xm5VQz6gluXQ2pejgt3khUOv6YTsF49EQ7q1Ls7FxoNapz1gR88XCZ BS6zkcVzS2IWxXDYm5cJrfbJBUUGPoUcOJgGgMC56+np9en9wKg7VeHAhJZDKkDi XDkd0N6qqry2sX1e/CSfXzWaS+PrOl+kP7Z+miAeqIgxbUMv5FDIbcSmNtsm4Ex8 GGOWRgp47Cfy/5sg28YCS7T0Z5j89vmCDbYfnT9GRYhh+kPODDd8VsGI1Pmf0sZ/ W9498+MG89aMNZinnCV6WcgycoKxUMKUmzu/vL5EJCUuPaQZB41L0rIMSOFmAxAO 1ByTAzyP/+jTnEipOXfHMkVr1PpA3Q6nGTX3JArfEQ5xA6Ph1kvIEcTg0nOFKaHe Qfy219fixE64L+D1+zcu+KBPtmr8mxa//vZGLgXwK683mdounUihMO5r30uKLo+s 9Axu4xBn825bajLL7fd1zb3//abGF/W2UuExzBG//Qg7nFEWxD2Wpfe1dDyKtK+X NkBST05pPEpkzWq55eo2ewxLNtDucGIpA6KY7msm1yXA521LGF8= =Z5Zn -----END PGP SIGNATURE----- --TcijPd03MczgHlFS--