Re: Upstream asks: unportable patch for mirrormagic?
Hello Lukas,
> > > > - gi->checked = va_arg(ap, boolean);
> > > > + gi->checked = (boolean) va_arg(ap, int);
[...]
> Well, the patch should be correct ANSI C, I wonder how it worked on other
> architectures before. The reason is that a function with variable argument
> list gets called with an argument of type unsigned char, so this first is
> a case for "default promotion" to int. The corresponding paragraph from
> the glibc documentation:
>
> Since the prototype doesn't specify types for optional arguments, in a
> call to a variadic function the default argument promotions are
> performed on the optional argument values. This means the objects of
> type char or short int (whether signed or not) are promoted to either
> int or unsigned int, as appropriate; and that objects of type float are
> promoted to type double. So, if the caller passes a char as an optional
> argument, it is promoted to an int, and the function can access it with
> va_arg (ap, int).
This seems to be the solution -- thanks a lot for making this clear!
Best regards,
Holger
--
// Holger Schemel |
\X/ aeglos@valinor.owl.de | Microsoft -- confusion at your fingertips.
Reply to: