From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8EAD73858C52; Tue, 5 Mar 2024 22:12:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EAD73858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709676777; bh=tNnF4EG28048+8V9+ZHB8GrxAncbvGrn5RWPPQ44W38=; h=From:To:Subject:Date:From; b=DXRGcgjnhSZ/tamlzLCM1kSm5XkWFWrhmhELN83TvsJWI//LEnC5voiqRrS5u92HN MiHnR7SydKpxtkVAIgBPBlv1YZ8yAnRwuMUynXb5SQzjx9ZzIbbqegX8iMr0S9L3h4 mW1vwJoeJXI2g9dTEHpNY9fbEud5YAFoLUf2f2Cc= From: "patrick at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/114247] New: RISC-V: miscompile at -O3 Date: Tue, 05 Mar 2024 22:12:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: patrick at rivosinc dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114247 Bug ID: 114247 Summary: RISC-V: miscompile at -O3 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: patrick at rivosinc dot com Target Milestone: --- Testcase: int printf(const char *, ...); union a { unsigned short b; int c; signed short d; }; int e, f =3D 1, g; long h; const int **i; void j(union a k, int l, unsigned m) { const int *a[100]; i =3D &a[0]; h =3D k.d; } static int o(union a k) { k.d =3D -1; while (1) if (f) break; j(k, g, e); return 0; } int main() { union a n =3D {1}; o(n); printf("dec: %ld\n", h); printf("hex: %lX\n", h); } Commands: > riscv64-unknown-linux-gnu-gcc -O3 red.c -o red.out -fno-strict-aliasing -= fwrapv -fno-aggressive-loop-optimizations > qemu-riscv64 red.out dec: 65535 hex: FFFF > riscv64-unknown-linux-gnu-gcc -O2 red.c -o red.out -fno-strict-aliasing -= fwrapv -fno-aggressive-loop-optimizations > qemu-riscv64 red.out dec: -1 hex: FFFFFFFFFFFFFFFF This testcase looks very suspect but AFAICT it doesn't contain any UB. Found via fuzzer=