public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114247] New: RISC-V: miscompile at -O3
@ 2024-03-05 22:12 patrick at rivosinc dot com
  2024-03-05 23:29 ` [Bug ipa/114247] RISC-V: miscompile at -O3 and IPA SRA pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: patrick at rivosinc dot com @ 2024-03-05 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

            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 = 1, g;
long h;
const int **i;
void j(union a k, int l, unsigned m) {
  const int *a[100];
  i = &a[0];
  h = k.d;
}
static int o(union a k) {
  k.d = -1;
  while (1)
    if (f)
      break;
  j(k, g, e);
  return 0;
}
int main() {
  union a n = {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

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

end of thread, other threads:[~2024-05-15 13:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 22:12 [Bug target/114247] New: RISC-V: miscompile at -O3 patrick at rivosinc dot com
2024-03-05 23:29 ` [Bug ipa/114247] RISC-V: miscompile at -O3 and IPA SRA pinskia at gcc dot gnu.org
2024-03-06  8:00 ` rguenth at gcc dot gnu.org
2024-04-03 15:33 ` jamborm at gcc dot gnu.org
2024-04-04 12:12 ` jamborm at gcc dot gnu.org
2024-04-04 12:14 ` rdapp at gcc dot gnu.org
2024-04-04 13:04 ` rdapp at gcc dot gnu.org
2024-04-04 21:39 ` jamborm at gcc dot gnu.org
2024-04-04 21:44 ` patrick at rivosinc dot com
2024-04-05 16:26 ` jamborm at gcc dot gnu.org
2024-05-15 13:46 ` cvs-commit at gcc dot gnu.org
2024-05-15 13:47 ` jamborm at gcc dot gnu.org

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).