C++ bug: va_arg & aggr type

Nathan Sidwell nathan@acm.org
Mon Oct 4 08:00:00 GMT 1999

The current CVS rejects va_arg applied to an aggregate type.
#include <stdarg.h>
struct X {int m;};   
void fn1(va_list args)
  int i = va_arg (args, int);
  X x = va_arg (args, X);
I get,
nathan@manao:611>/local/nathan/devel/bin/devel-gcc -c -ansi -pedantic foo.cc -v
Reading specs from /local/nathan/devel/lib/gcc-lib/sparc-sun-solaris2.6/2.96/specs
gcc version 2.96 19991004 (experimental)
 /local/nathan/devel/lib/gcc-lib/sparc-sun-solaris2.6/2.96/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=96 -D__cplusplus -trigraphs -D__STRICT_ANSI__ -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -pedantic -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) foo.cc /var/tmp/ccGe2Joj.ii
GNU CPP version 2.96 19991004 (experimental) (sparc)
#include "..." search starts here:
#include <...> search starts here:
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /local/nathan/devel/lib/gcc-lib/sparc-sun-solaris2.6/2.96/cc1plus /var/tmp/ccGe2Joj.ii -quiet -dumpbase foo.cc -pedantic -ansi -version -o /var/tmp/ccCwgr9v.s
GNU C++ version 2.96 19991004 (experimental) (sparc-sun-solaris2.6) compiled by GNU C version 2.95 19990728 (release).
foo.cc: In function `void fn1 (void *)':
foo.cc:8: non-lvalue in unary `&'

I attach the preprocessed source.

I can't see anything in the standard banning va_args on structs. This is a regression
from the 2.95 release. I'll install this as an XFAILING test case, if that's ok?


Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
# 1 "foo.cc"
# 1 "/local/nathan/devel/lib/gcc-lib/sparc-sun-solaris2.6/2.96/include/stdarg.h" 1 3 4
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
# 124 "/local/nathan/devel/lib/gcc-lib/sparc-sun-solaris2.6/2.96/include/stdarg.h" 3 4
# 1 "foo.cc" 2
struct X {int m;};

void fn1(va_list args)
  int i = __builtin_va_arg  (args, int);
  X x = __builtin_va_arg  (args, X);

More information about the Gcc-bugs mailing list