This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: C++ bug: va_arg & aggr type
- To: nathan at compsci dot bristol dot ac dot uk
- Subject: Re: C++ bug: va_arg & aggr type
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Mon, 04 Oct 1999 18:57:20 +0200
- Cc: egcs-bugs at egcs dot cygnus dot com
- References: <4.2.0.58.19991004172017.00c3fe40@mail.lauterbach.com>
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
>testcases.
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')
abort();
if (*msg != '2')
abort();
va_start( ap, msg );
if ( va_arg(ap,int) != 3)
abort();
if ( va_arg(ap,int) != 4)
abort();
if ( va_arg(ap,int) != 5)
abort();
if ( va_arg(ap,int) != 6)
abort();
if ( va_arg(ap,int) != 7)
abort();
if ( va_arg(ap,int) != 8)
abort();
if ( va_arg(ap,int) != 9)
abort();
va_end( ap );
}
int main(void)
{
debug("1 filepointer", "2 format", 3, 4, 5, 6, 7, 8, 9);
exit(0);
}
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.
Franz.