C++ bug: va_arg & aggr type

Franz Sirl Franz.Sirl-kernel@lauterbach.com
Sun Oct 31 23:03:00 GMT 1999

At 18:25 04.10.99 , Nathan Sidwell wrote:
>Franz Sirl wrote:
> >
> > Now that the code paths for vararg functions are not automatically tested
> > via other generic C++ tests, there should be quite a few testcases testing
> > the _functionality_ in C++ of the __builtin_va* stuff. A first step would
> > be to convert (a simple copy & mv *.c *.cc?) all the C va-arg-*.c testcases
> > to C++ I believe.
>Some of those tests use <vararg.h> &/| old-style protos. Junking those tests
>and dinking the remainder into C++ testsuite format gives a set of passing

Ok. Good they pass for you. The one testcase that doesn't pass for me 
(Linux/PPC) and isn't in the C++ testsuite (a similar testcase is PPC 
specific in gcc.dg) yet is:

#include <stdarg.h>
static int test=23;
inline void debug(const char *fp, const char *msg, ...)
        int local_var[10] = {10,};
        va_list ap;

        local_var[0] += test;

        if (*fp != '1')
        if (*msg != '2')

        va_start( ap, msg );

        if ( va_arg(ap,int) != 3)
        if ( va_arg(ap,int) != 4)
        if ( va_arg(ap,int) != 5)
        if ( va_arg(ap,int) != 6)
        if ( va_arg(ap,int) != 7)
        if ( va_arg(ap,int) != 8)
        if ( va_arg(ap,int) != 9)
        va_end( ap );

int main(void)
      debug("1 filepointer", "2 format", 3, 4, 5, 6, 7, 8, 9);

Removing either inline or the local_var stuff lets it pass. Does this one 
work for you?

>All those tests deal with scalar vars and making sure the stack frame is laid
>out in an accessible form. It seems the case I have is not there, so probably
>should be in the gcc testsuite too.

I forgot to mention in my last email that the error message you describe 
happens in C with code like that:

         tmp = &va_arg (ap, int);

This used to compile with gcc-2.95, but I believe this construct is illegal 
according to the standard (I think Richard told me so). I have been told 
that it happens to work on some platforms, but it definitely fails 
(produces non-working code) on Linux/PPC.


More information about the Gcc-bugs mailing list