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

            Bug ID: 112988
           Summary: [14] RISC-V vector: Variadic function call causes
                    runtime failure
           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 a = 0;
int p, q, r, x = 230;
short d;
int e[256];
static struct f w;
int *c = &r;

short y(short z) {
  return z * d;
}

#pragma pack(1)
struct f {
  int g;
  short h;
  int j;
  char k;
  char l;
  long m;
  long n;
  int o;
} s = {1}, v, t, *u = &v, *b = &s;

void add_em_up(int count, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap, count);
  __builtin_va_end(ap);
}

int main() {
  int i = 0;
  for (; i < 256; i++)
    e[i] = i;

  p = 0;
  for (; p <= 0; p++) {
    *c = 4;
    *u = t;
    x |= y(6 >= q);
  }

  *b = w;

  add_em_up(1, 1);

  if (a != 0)
    return 1;
  if (q != 0)
    return 2;
  if (p != 1)
    return 3;
  if (r != 4)
    return 4;
  if (x != 0xE6)
    return 5;
  if (d != 0)
    return 6;

  return 0;
}

Commands:
rv64gcv
> /scratch/tc-testing/tc-dec-11-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -march=rv64gcv -mabi=lp64d -O3 red.c -o rv64gcv.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0 
> /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/qemu-riscv64 rv64gcv.out
> echo $?
3

rv64gc
> /scratch/tc-testing/tc-dec-11-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -march=rv64gc -mabi=lp64d -O3 red.c -o rv64gc.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0 
> /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/qemu-riscv64 rv64gc.out
> echo $?
0

Godbolt:
https://godbolt.org/z/Pq7Yns56G

Testcase seems very similar to pr112929, filing this bug to give people an
additional testcase to look at :)

Reply via email to