From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A6453858CDB; Mon, 13 May 2024 00:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A6453858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715561866; bh=kGkqrmp7h4ubQCqE0/LlbANRUPYjR3POsKoIaK4zZbo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jwiDGJzwDDcYgtTfEpxTcb1ZImYdaFc8h5FGzmI4pNvD+Zyhk4TNJqZxdavaCXUGK 2QbicgNCMMDpMU1Y0QK8vT4prV3OYCoumy1rvyJo+rGRD1cg9knu8/T5u0wGhc+kLM dJw/3QE53Q4/1u/fV+cj0xBBH3dhOEjOF0boaNKk= From: "sjames at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/115056] [14/15 regression] Miscompilation (also triggering -Wstringop-overflow and -Warray-bounds warning) when -O2 or higher Date: Mon, 13 May 2024 00:57:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.1.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sjames at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115056 --- Comment #7 from Sam James --- Isn't there still an uninitialised read? ``` $ valgrind /tmp/foo [...] =3D=3D814922=3D=3D 1886221359 1 0 0 0 0 0 =3D=3D814922=3D=3D Use of uninitialised value of size 8 =3D=3D814922=3D=3D at 0x48F7D3A: _itoa_word (_itoa.c:183) =3D=3D814922=3D=3D by 0x49029A6: __printf_buffer (vfprintf-process-arg.c= :155) =3D=3D814922=3D=3D by 0x4904BD0: __vfprintf_internal (vfprintf-internal.= c:1544) =3D=3D814922=3D=3D by 0x49C55AE: __printf_chk (printf_chk.c:33) =3D=3D814922=3D=3D by 0x10938D: main (/tmp/foo.c:16) =3D=3D814922=3D=3D ``` with: ``` #include #include typedef union { unsigned char as_bytes[64]; unsigned long long as_chunks[64 / sizeof(unsigned long long)]; } Block; int main(int argc, char **argv) { Block block; int i =3D strlen(argv[0]), j =3D 0; for (; j < i; j++) block.as_bytes[j] =3D argv[0][j]; block.as_bytes[j] =3D 0x01; // I removed this line while (++j & 7) block.as_bytes[j] =3D 0; if (j > 56) while (j < 64) block.as_bytes[j++] =3D 0; while (j < 56) block.as_bytes[j++] =3D 0; for (j =3D 0; j < 8; j++) printf("%d\n", (int)block.as_chunks[j]); } ```=