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

            Bug ID: 64979
           Summary: S/390: va_list overflow area pointer is not setup due
                    to stdarg optimization
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org

Created attachment 34699
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34699&action=edit
Experimental fix

The following testcase aborts when compiled with at least -O1:

#include <stdarg.h>

extern void abort (void);

void __attribute__((noinline))
bar(int msgno, va_list *args)
{
  int i;

  for (i = 0; i < 10; i++)
    if (i != va_arg(*args, int))
      abort ();
}


void __attribute__((noinline))
foo(int msgno, ...)
{
  va_list args;
  int nargs;

  va_start(args, msgno);
  nargs = va_arg(args, int);
  bar(msgno, (va_list *)((nargs == 0) ? ((void *)0) : &args));
}


int main(void)
{
  foo(100 /* msgno */,
      1 /* nargs - part of vararg list */,
      0, 1, 2, 3, 4, 5, 6, 7, 8, 9);

  return 0;
}

It is present since we enabled stdarg optimization in the S/390 backend:
https://gcc.gnu.org/ml/gcc-patches/2005-05/msg02429.html

The field __overfloat_arg_area in the va_list struct is not set up if the
va_arg expansions in the current function are found not to exceed the number of
argument registers. This fails with the testcase since the va_list pointer is
passed to another function - still needing that field.

The final patch will include the testcase.

Reply via email to