Article View: comp.std.c
Article #22Re: stdarg facility, va_start more than once?
From: Ronald F. Guilmette
Date: Wed, 28 Oct 1992 18:58
Date: Wed, 28 Oct 1992 18:58
35 lines
2130 bytes
2130 bytes
In article <MGK.92Oct27155222@cedar.sql.sybase.com> mgk@sql.sybase.com (Michael Keirnan aka Joe Cool) writes:
>Is using the macro va_start more than once in a function legal in
>ANSI C? ...
I have wondered about this also.
The standard isn't very clear on this point. However there is a subtle
hint in section 4.8.1.3 (va_end macro). It says:
"The va_end macro may modify ap so that it is no longer usable
(without an intervening invocation of va_start)."
Clearly, the implication is that you can call va_start once, then call
va_end, and then call va_start again... but I wish that the standard
had come right out and said this... and said that you (as a programmer)
have every right to expect this sequence to do what you would intutively
think that it ought to do (i.e. take you back again to the start of the
variable argument list and let you "start over" on stepping through it
with va_arg).
The question is *NOT* raised merely by attempts to read the standard in
a "twisted" way. In fact some implementors may simply not consider the
possibility that a programmer may want to "start over" in this way. (As
far as I know, the stdarg implementation used by GCC for several targets
DOES NOT "correctly" support multiple invocations of va_start during any
single invocation of a given stdarg function... and it is certainly not
clear that the standard requires it to.)
--
// Ron ("Loose Cannon") Guilmette
// uucp: ...uunet!lupine!segfault!rfg
// New new motto: Quality control is a state of mind.
// misc.forsale.computers ad, circa 2007:
// Used Cray wrist watch for sale; 25 bucks or best offer.
Technical Details
Message-ID:
<1992Oct28.185832.9180@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!decwrl!netcomsv!netcom.com!rfgReferences:
<MGK.92Oct27155222@cedar.sql.sybase.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!decwrl!decwrl!netcomsv!netcom.com!rfg From: rfg@netcom.com (Ronald F. Guilmette) Subject: Re: stdarg facility, va_start more than once? Message-ID: <1992Oct28.185832.9180@netcom.com> Organization: Netcom Online Communications Services (408-241-9760 login: guest) References: <MGK.92Oct27155222@cedar.sql.sybase.com> Distribution: comp Date: Wed, 28 Oct 1992 18:58:32 GMT Lines: 35