public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/116318] New: RISC-V: Miscompile at -O1 with -fwhole-program
@ 2024-08-09 23:56 patrick at rivosinc dot com
  2024-08-09 23:59 ` [Bug target/116318] " andrew at sifive dot com
  2024-08-10  0:02 ` patrick at rivosinc dot com
  0 siblings, 2 replies; 3+ messages in thread
From: patrick at rivosinc dot com @ 2024-08-09 23:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116318

            Bug ID: 116318
           Summary: RISC-V: Miscompile at -O1 with -fwhole-program
           Product: gcc
           Version: 15.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 a, c, d;
short b[][8] = {};
int main() {
  for (; d < 7; d++) {
    a = b[d][c];
    __builtin_printf("%lX\n", a ^ 4095UL);
  }
}

Commands:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc -fwhole-program -O1 preprocessed.c -o test.o
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.o
14FE
FC3
F97
75FC
FE7
FEB
FFF

> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc -fwhole-program -O0 preprocessed.c -o test.o
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.o
FFF
FFF
FFF
FFF
FFF
FFF
FFF

Found via fuzzer.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/116318] RISC-V: Miscompile at -O1 with -fwhole-program
  2024-08-09 23:56 [Bug target/116318] New: RISC-V: Miscompile at -O1 with -fwhole-program patrick at rivosinc dot com
@ 2024-08-09 23:59 ` andrew at sifive dot com
  2024-08-10  0:02 ` patrick at rivosinc dot com
  1 sibling, 0 replies; 3+ messages in thread
From: andrew at sifive dot com @ 2024-08-09 23:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116318

Andrew Waterman <andrew at sifive dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrew at sifive dot com

--- Comment #1 from Andrew Waterman <andrew at sifive dot com> ---
Isn't this UB since the accesses to b are out of bounds?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/116318] RISC-V: Miscompile at -O1 with -fwhole-program
  2024-08-09 23:56 [Bug target/116318] New: RISC-V: Miscompile at -O1 with -fwhole-program patrick at rivosinc dot com
  2024-08-09 23:59 ` [Bug target/116318] " andrew at sifive dot com
@ 2024-08-10  0:02 ` patrick at rivosinc dot com
  1 sibling, 0 replies; 3+ messages in thread
From: patrick at rivosinc dot com @ 2024-08-10  0:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116318

Patrick O'Neill <patrick at rivosinc dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Patrick O'Neill <patrick at rivosinc dot com> ---
(In reply to Andrew Waterman from comment #1)
> Isn't this UB since the accesses to b are out of bounds?

Ah dang it you're right - thanks. I'll re-reduce from the original testcase.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-10  0:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-09 23:56 [Bug target/116318] New: RISC-V: Miscompile at -O1 with -fwhole-program patrick at rivosinc dot com
2024-08-09 23:59 ` [Bug target/116318] " andrew at sifive dot com
2024-08-10  0:02 ` patrick at rivosinc dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).