cURL / Mailing Lists / curl-library / Single Mail


Re: curl_easy_setopt and typeof

From: Nathan E. Moore <>
Date: Mon, 14 Apr 2008 00:37:53 -0400

--On Sunday, April 13, 2008 5:45 PM -0700 Dan Fandrich
<> wrote:

> On Sun, Apr 13, 2008 at 01:42:08PM -0400, Nathan E. Moore wrote:
>> Section The va_arg macro (also available at
>> <>)
>> ...
>> The parameter type shall be a type name specified such that the type of
>> a pointer to an
>> object that has the specified type can be obtained simply by postfixing
>> a * to type. If
>> there is no actual next argument, or if type is not compatible with the
>> type of the
>> actual next argument (as promoted according to the default argument
>> promotions), the
>> behavior is undefined, except for the following cases:
> ^^^^^^^^^^^^^^^^^^^^^
>> — one type is a signed integer type, the other type is the
>> corresponding unsigned integer
>> type, and the value is representable in both types;
>> — one type is pointer to void and the other is a pointer to a
>> character type.
>> I guess the way I read it says that you do get argument promotion. I
>> would assume the
>> promotion would be done prior to pushing the arguments onto the stack.
>> But I have been
>> wrong before and likely will be again.
> There is now way the compiler would know the expected type at the time of
> calling in order to do the promotion. The behaviour in this case is, as
> documented, undefined.
>>>> Dan

Indeed there is no way for the compiler to know that information short of
solving the
halting problem, but that is not what I meant. I meant that floats are all
promoted to
doubles, smaller integral types to long/unsigned long, before the function
call is made.
This interpretation matches what the specs for printf say about the length
modifiers (see

Nathan Moore
Received on 2008-04-14