Re: backtrace

From: Date: Fri, 01 Sep 2000 12:46:23 +0000
Subject: Re: backtrace
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-31562@lists.php.net to get a copy of this message
On Fri, 1 Sep 2000, Sascha Schumann wrote: > > > > Can you forward me your Email? My understanding is that if it compiles, > > > > it should work. > > > > > > Well, it works under some conditions, as does Win2000. > > > > It works if it compiles, sarcasm aside. > > main(){*(char*)0=1;} > > compiles as well, but does not work on most platforms. Huh? I didn't say everything works if it compiles. I said copying va_list's works if it compiles. > > > 1.: "The object ap may be passed as an argument to another > > > function; if that function invokes the va_arg macro > > > with parameter ap, the value of ap in the calling > > > function is indeterminate and shall be passed to the > > > va_end macro prior to any further reference to ap. > > > > Where are you reading this? It sounds very odd and I assume it would be > > wrong (or otherwise useless to do) on every implementation. > > "7.15 Variable arguments <stdarg.h>," paragraph 3, page 262, > ISO/IEC 9899:1999. So it falls under the 'otherwise useless to do' IMO. > > > 2.: There are two ways to reinitialize a va_list. Old > > > implementations don't support va_copy. va_start cannot > > > be used in a function with a fixed number of arguments. > > > > Essentially, it means that a function that receives a va_list argument, > > cannot use it more than once (unless it uses the non portable va_copy()). > > Sounds weird to me. > > Footnote (212) implies that it is permitted to pass a pointer > to the object, instead of the object itself, so that the > other constraints don't apply. It does not discuss any > further semantics of this operation though (which is logical, > since conforming implementations will supply va_copy). > > So, if we should ever need this kind of functionality, the > function should be declared as > > type f(params, va_list *ap); > > To use ap, we would need to initialize a private copy: > > va_list f; > > va_copy(f, *ap); > va_arg(f, ..); > > Since va_copy is not available everywhere, we define it as: > > #ifndef va_copy > #define va_copy(dest, src) memcpy((dest),(src),sizeof(*(src))) > #endif > > This should be safe, unless va_arg modifies anything else > beside the va_list it operates on. That's mostly right. Essentially it assumes almost as much as va_list foo = va_list bar; assumes. The only difference is that in this case, implementations may also use arrays to represent va_list (because arrays cannot be lvalues). Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/

« previous php.dev (#31562) next »