This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix gcc.c-torture/execute/stdarg-2.c


Hello,

The testcase is miscompiled on the SPARC because of the following construct:

  foo_arg = va_arg (ap, int) + va_arg (ap, double);

I think it is not valid ISO C because ap is modified twice without an 
intervening sequence point.

OK for mainline?


2004-11-03 ?Eric Botcazou ?<ebotcazou@libertysurf.fr>

	* gcc.c-torture/execute/stdarg-2.c (foo): Split multiple
	invocations of va_arg.


-- 
Eric Botcazou
Index: gcc.c-torture/execute/stdarg-2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/stdarg-2.c,v
retrieving revision 1.1
diff -u -p -r1.1 stdarg-2.c
--- gcc.c-torture/execute/stdarg-2.c	29 Sep 2004 09:47:55 -0000	1.1
+++ gcc.c-torture/execute/stdarg-2.c	3 Nov 2004 20:52:39 -0000
@@ -13,14 +13,17 @@ foo (int v, va_list ap)
   switch (v)
     {
     case 5:
-      foo_arg = va_arg (ap, int) + va_arg (ap, double);
+      foo_arg = va_arg (ap, int);
+      foo_arg += va_arg (ap, double);
       foo_arg += va_arg (ap, long long);
       break;
     case 8:
-      foo_arg = va_arg (ap, long long) + va_arg (ap, double);
+      foo_arg = va_arg (ap, long long);
+      foo_arg += va_arg (ap, double);
       break;
     case 11:
-      foo_arg = va_arg (ap, int) + va_arg (ap, long double);
+      foo_arg = va_arg (ap, int);
+      foo_arg += va_arg (ap, long double);
       break;
     default:
       abort ();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]