Re: [gtk-list] gtk+-1.2.5 va_args fix...



On Wed, 6 Oct 1999, Ani Joshi wrote:

> 
> 	I ran into problems with gtk+-1.2.5 and gcc-2.95.2pre with a bunch
> of bad va_arg() calls.  The new compiler is now pretty strict on these.
> Attatched you will find a patch which fixes the bad va_arg() calls.

hm, judging from your patch, gcc-2.95.2pre is completely broken on var args
handling (excerpt):

     case GTK_TYPE_FLAGS: \
-      GTK_VALUE_FLAGS (*arg) = va_arg (var_args, guint); \
+      GTK_VALUE_FLAGS (*arg) = (guint)va_arg (var_args, int); \

va_arg() should return nothing else than the type specified, see stdarg(3):

       type va_arg( va_list ap, type);

       The va_arg macro expands to an  expression  that  has  the
       type  and  value  of  the  next argument in the call.  The
       parameter ap is the va_list ap  initialized  by  va_start.
       Each  call  to  va_arg  modifies  ap so that the next call
       returns the next argument.  The parameter type is  a  type
       name  specified so that the type of a pointer to an object
       that has the specified type  can  be  obtained  simply  by
       adding a * to type.


       break; \
  \
       /* we collect longs as glongs since they differ in size with \
        * integers on some platforms \
        */ \
     case GTK_TYPE_LONG: \
-      GTK_VALUE_LONG (*arg) = va_arg (var_args, glong); \
+      GTK_VALUE_LONG (*arg) = (glong)va_arg (var_args, int); \
       break; \
     case GTK_TYPE_ULONG: \
-      GTK_VALUE_ULONG (*arg) = va_arg (var_args, gulong); \
+      GTK_VALUE_ULONG (*arg) = (gulong)va_arg (var_args, int); \
       break; \

and this is completely broken, sizeof(long)!=sizeof(int) on 64 bit
machines for instance.

thanks for your patch anyways, but i think you'd better send the
report off to the gcc maintainers.

> 
> 
> Ani
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]