Re: [hatari-devel] undefined behaviour fixes |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Andreas Grabher <andreas_g86@xxxxxxxxxx>
- Subject: Re: [hatari-devel] undefined behaviour fixes
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Mon, 6 Jan 2025 18:27:58 +0000
- Cc: hatari-devel@xxxxxxxxxxxxxxxxxxx, Toni Wilen <twilen@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1736188082; bh=pQsWefKgsLV9EaKvaBhFlTHBOHsxXvokLhLDtblSnZ4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=E2wlkD44LTx9IpGCbit2GO6vnqHc97ymNQ4OYlVPOudBv3SG4xHoXqV8d4i9H9phf lX2IG23lCxR+aJ14xCcRcvFiI/zAhS3p1TC2cUwzdwMuHgrkVE8Pq79T3diskkKEhe X+glC7A0oJWbV2iLo7RkZBZNp2UXqr0pbmrBXabL+pNjKmaFh4aJWZs4bun/sivSGm gpAscn05YpZK77TVd4vFDWXLXMPRtbEU32Hfk1neCkWa9aSzyGB7YBgD/qsi7v/4WJ XDtCo6rYkk8gTT9Uk5RStkYnOvL6bKvn6T33LxRA7xgYts5GapZrK9uhmgRVrfQ13F MietiZrrlm+HQ==
Am Mon, 6 Jan 2025 14:11:05 +0100
schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
....
> Using -fwrapv flag with my compiler reduces the amount of warnings.
Thanks for checking - that patch looks more reasonable to me now.
> There are still some warnings about shifting beyond type size (uae_u32 x
> >> 32 and uae_u32 x << 32) and shifting with negative value (x << -1).
> Appended patch should fix them.
diff -ru a/src/cpu/gencpu.c b/src/cpu/gencpu.c
--- a/src/cpu/gencpu.c 2024-05-04 20:10:03
+++ b/src/cpu/gencpu.c 2025-01-06 14:04:13
@@ -9224,7 +9224,7 @@
if (curi->dmode == Dreg) {
out("uae_u32 tmp = m68k_dreg(regs, dstreg);\n");
out("offset &= 0x1f;\n");
- out("tmp = (tmp << offset) | (tmp >> (32 - offset));\n");
+ out("tmp = (offset > 0 && offset < 32) ? ((tmp << offset) | (tmp >> (32 - offset))) : tmp;\n");
offset is restricted to 0x1f, so it is always < 32, i.e. it should be
sufficient to check for "offset != 0" in above condition. I'd maybe also
rather write it like this:
out("tmp = (tmp << offset)\n");
out("if (offset) tmp |= (tmp >> (32 - offset));\n");
?
Thomas