Yep, the spec goes right. a corresponding va_end() dtor should be applied 
to ap once ap has been initialized by a va_start().
IMO no va_end() is needed without a preceding va_start(), and it doesn't 
matter if ap is used between va_start() and va_end().

BTW, could anyone commit this patch if there seems no problem?

Moriyoshi

[EMAIL PROTECTED] (Marcus Börger) wrote:

> Some comments on ISO9899 standard
> 7.15.1.3-2 Read between the lines: without va_end the behaviour is undefined.
>   What ever that means i guess you have to call va_end and that requires 
> va_start.
> 
> 7.15.1.4-3 Says do not call va_start twice without va_end.
> 
> marcus
> 
> 
> ISO/IEC 9899:1999 (E) ©ISO/IEC
> 
> 7.15.1.3 The va_end macro
> Synopsis
> 1 #include <stdarg.h>
> void va_end(va_list ap);
> Description
> 2 The va_end macro facilitates a normal return from the function whose variable
> argument list was referred to by the expansion of va_start, or the function 
> containing
> the expansion of va_copy, that initialized the va_list ap. The va_end macro may
> modify ap so that it is no longer usable (without an intervening invocation 
> of va_start
> or va_copy). If there is no corresponding invocation of the va_start or va_copy
> macro, or if the va_end macro is not invoked before the return, the behavior is
> undefined.
> Returns
> 3 The va_end macro returns no value.
> 
> 7.15.1.4 The va_start macro
> Synopsis
> 1 #include <stdarg.h>
> void va_start(va_list ap, parmN);
> Description
> 2 The va_start macro shall be invoked before any access to the unnamed 
> arguments.
> 3 The va_start macro initializes ap for subsequent use by va_arg and va_end.
> va_start (or va_copy) shall not be invoked again for the same ap without an
> intervening invocation of va_end for the same ap.
> (...)
> 
> 
> At 10:47 08.11.2002, Moriyoshi Koizumi wrote:
> >See http://www.opengroup.org/onlinepubs/007908799/xsh/stdarg.h.html
> >This appears to imply that va_start() can be used more than twice.
> >
> >And I don't think va_start() always has to be invoked.
> >
> >Moriyoshi
> >
> >[EMAIL PROTECTED] (Marcus Börger) wrote:
> >
> > > I am not sure if va_start can be called twice in a row (rekursive).
> > > Manual does not say anything about that.
> > >
> > > How about:
> > >
> > > cvs -z3 -q diff zend_hash.c (in directory S:\php4-HEAD\Zend)
> > > Index: zend_hash.c
> > > ===================================================================
> > > RCS file: /repository/ZendEngine2/zend_hash.c,v
> > > retrieving revision 1.93
> > > diff -u -r1.93 zend_hash.c
> > > --- zend_hash.c 5 Nov 2002 18:22:02 -0000       1.93
> > > +++ zend_hash.c 8 Nov 2002 09:32:48 -0000
> > > @@ -722,9 +722,13 @@
> > >
> > >          HASH_PROTECT_RECURSION(ht);
> > >
> > > -       va_start(args, num_args);
> > >          p = ht->pListHead;
> > > +       if (p == NULL) {
> > > +               va_start(args, num_args);
> > > +               va_end(args);
> > > +       }
> > >          while (p != NULL) {
> > > +               va_start(args, num_args);
> > >                  hash_key.arKey = p->arKey;
> > >                  hash_key.nKeyLength = p->nKeyLength;
> > >                  hash_key.h = p->h;
> > > @@ -733,8 +737,8 @@
> > >                  } else {
> > >                          p = p->pListNext;
> > >                  }
> > > +               va_end(args);
> > >          }
> > > -       va_end(args);
> > >
> > >          HASH_UNPROTECT_RECURSION(ht);
> > >   }
> > >
> > >
> > > marcus
> > >
> > > At 09:52 08.11.2002, Moriyoshi Koizumi wrote:
> > > >Hi,
> > > >
> > > >The attached patch is a probable fix for bug #19566. I guess the bug
> > > >is that va_list is not properly initialized before each callback function
> > > >call. I've tested it in PPC linux, and it works fine.
> > > >
> > > >Regards,
> > > >Moriyoshi
> > > >
> > > >
> > > >--
> > > >PHP Development Mailing List <http://www.php.net/>
> > > >To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to