|
From: | Tim McIntosh |
Subject: | Re: Fix, GDL2, EOQualifier (getKey()): args |
Date: | Wed, 23 Apr 2008 09:56:35 -0500 |
On Apr 23, 2008, at 6:34 AM, David Ayers wrote:
this is addressing changes in EOQualifier getKey(), made on March 30.2008-03-30 Matt Rice <ratmice@gmail.com> (getKey): Don't use a pointer to a va_list. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14557This doesn't work without a pointer to args (I am using Mac OS 10.4 with Intel CPU). It will just stick with the first argument, so obviously thepointer incremented in the use of va_arg() will not return. Quote from the discussion on bugzilla:I don't see anything wrong with using "va_list *". The standard evensays:It is permitted to create a pointer to a va_list and pass that pointer to another function, in which case the original function may make further use of the original list after the other function returns. About passing by value it says: 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 apThanks for the report and the patch! The change was provoked by issues compiling on x86_64. I don't suppose you can test it there? What wouldbe great is if we could extract the relevant code into a simple test case for gcc to insure that our approach is portable.
What I gather from the above is:1. After passing ap to another function by value, it is not valid to use ap in the caller without re-initializing it. Currently _qualifierWithArgs() is violating this rule by passing 'args' in two sequential calls to getKey().
2. It is valid to do this if ap is instead passed by pointer (as in the original code and proposed changes).
3. Taking the address of a va_list that has been passed by value is unportable (see GCC bug comment #14). The original code and the proposed changes do this. It looks like this could be fixed by changing _qualifierWithArgs() to take 'va_list *' instead of 'va_list' and eliminating (or similarly changing the signature of) - qualifierWithQualifierFormat:varargList:.
-Tim
[Prev in Thread] | Current Thread | [Next in Thread] |