Different behaviour of stdarg as function of platform, is this a bug?

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Wed Jun 7 15:53:00 GMT 2000


On Thu, 08 Jun 2000, Zack Weinberg wrote:
> On Thu, Jun 08, 2000 at 12:29:21AM +0200, Franz Sirl wrote:
> > On Thu, 08 Jun 2000, Zack Weinberg wrote:
> > > I think the footnote means you could get the ppc/linux behavior
> > > reliably by writing
> > >
> > > void vfoo(va_list *vl)
> > > {
> > >   int a, b;
> > >   a = va_arg(*vl, int);
> > >   b = va_arg(*vl, int);
> > >   printf("vfoo: %d %d\n", a, b);
> > > }
> > >
> > > void foo(int x, ...)
> > > {
> > >   int i;
> > >   va_list vl;
> > >   va_start(vl, x);
> > >   for (i = 0; i < 2; ++i)
> > >     vfoo(&vl);
> > >   va_end(vl);
> > > }
> > >
> > > but I would not do this in code intended to be portable.
> >
> > No, this doesn't change anything :-), va_list is an array in PPC-SYSV
> > ABI, so it will always be passed as a pointer.
>
> Yes, but on other platforms it is passed by value.  On those
> platforms, this should get you the same behavior as you get by default
> on PPC.

Argh, I misread your initial statement. Yes, you are right.

Franz.


More information about the Gcc mailing list