Subject: Re: va_list pointers, bad(?) gcc code
To: Frank van der Linden <>
From: Michal Ludvig <>
List: port-amd64
Date: 11/11/2003 14:53:18
Frank van der Linden told me that:
> I agree that this is better, but the thing is: this is 3rd party 
> code, (my test program jut imitates what's in glib 2.2.3), and I 
> think it's legal C code.. If it is legal C, then gcc should support 
> it. I'd like to find out if it's legal, and if this is considered a 
> bug.

Something more from the traffic on our internal mailing list...

Michal Ludvig
sUsE cR, s.R.o    | Cray is the only computer
(+420) 296.545.373 | that runs an endless loop
Personal homepage | in just four hours.

-------- Forwarded Message --------
Subject: Re: [development-gcc] [Fwd: va_list pointers, bad(?) gcc code]
Date: Tue, 11 Nov 2003 14:15:03 +0100 (CET)
From: Michael Matz <>
To: Michal Ludvig <>


On Tue, 11 Nov 2003, Michal Ludvig wrote:

> void vfoo1(const char *a, va_list l) 
> { 
> 	vfoo2(a, &l); 
> }

This here is the problem.  The object 'l' is not initialized through a
va_start, but instead by passing it from the calling function.  You
can't take the address of an _argument_ of type va_list, but you can
take it from a normally declared object of that type.  I.e. your
suggested fix:

> void vfoo1(const char *a, va_list l) 
> { 
> 	va_list l2;
> 	va_copy (l2, l); 
> 	vfoo2(a, &l2); 
> }

is correct.  But read below.

> However he still asks if his version is correct and so it was a 
> compiler bug that it didn't work, or wants to know where it is 
> written that it's illegal.

I can't find justification in the standard of why the initial program
should be non-conforming.  You are allowed to pass va_lists as 
parameters around (with the understanding that when you apply va_arg() 
to such arguments the passed va_list object in the caller becomes 
invalid).  And you are allowed to create and pass a pointer to a va_list 

So it appears that it also should be supported to create a pointer from 
an va_list argument.  I know that due to C's type rules regarding array 
types in argument lists we can't implement this on amd64, but it seems 
that this makes us not implement the standard correctly.