Interesting testcase for varargs

Geoff Keating geoffk@cygnus.com
Wed Mar 22 17:48:00 GMT 2000


This testcase explores an obscure corner of the array<->pointer decay
interaction with varargs.  It fails on ppc.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

===File /home/geoffk/patches/cygnus/egcs-vastart-test.patch===
2000-03-22  Geoff Keating  <geoffk@cygnus.com>

	* execute/va-arg-14.c: New test for va_start where the first
	parameter is a function argument.

Index: testsuite/gcc.c-torture/execute/va-arg-14.c
===================================================================
RCS file: va-arg-14.c
diff -N va-arg-14.c
*** /dev/null	Tue May  5 13:32:27 1998
--- va-arg-14.c	Wed Mar 22 17:44:15 2000
***************
*** 0 ****
--- 1,45 ----
+ #include <stdarg.h>
+ 
+ va_list global;
+ 
+ void vat(va_list param, ...)
+ {
+   va_list local;
+ 
+   va_start (local, param);
+   va_copy (global, local);
+   va_copy (param, local);
+   if (va_arg (local, int) != 1)
+     abort();
+   va_end (local);
+   if (va_arg (global, int) != 1)
+     abort();
+   va_end (global);
+   if (va_arg (param, int) != 1)
+     abort();
+   va_end (param);
+ 
+   va_start (param, param);
+   va_start (global, param);
+   va_copy (local, param);
+   if (va_arg (local, int) != 1)
+     abort();
+   va_end (local);
+   va_copy (local, global);
+   if (va_arg (local, int) != 1)
+     abort();
+   va_end (local);
+   if (va_arg (global, int) != 1)
+     abort();
+   va_end (global);
+   if (va_arg (param, int) != 1)
+     abort();
+   va_end (param);
+ }
+ 
+ int main(void) 
+ {
+   va_list t;
+   vat (t, 1);
+   exit (0);
+ }
============================================================


More information about the Gcc-patches mailing list