This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc-2.95.2 Odd warning on Sparc/Solaris7
- To: gcc at gcc dot gnu dot org
- Subject: gcc-2.95.2 Odd warning on Sparc/Solaris7
- From: Munagala Ramanath <Munagala dot Ramanath at postx dot com>
- Date: Sun, 15 Oct 2000 15:04:11 -0700
Hi,
The following simple program produces odd warnings that:
"warning: cannot pass objects of type `A' through `...'"
and the resulting executable prints wrong results; but if the
copy constructor is removed, the warnings go away and the
program works as expected.
I'm puzzled as to why an empty copy constructor should
have this effect; is this a bug in the compiler or is there something in
the standard that requires this behavior ?
Thanks.
Ram
//----------------------------------------------------------------------
// gcc-2.95.2 Sparc/Solaris7 emits warnings and the resulting executable
// prints wrong values. If the copy constructor in A is removed everything
// works as expected.
//
#include <stdio.h>
#include <stdarg.h>
struct A {
A( int j ) : i(j) {}
// if this copy constructor is removed, the warnings disappear and the
code
// works; with it, we get warnings like this:
// warning: cannot pass objects of type `A' through `...'
//
A( const A& a ) {};
int i;
};
void
f( int i, ... )
{
va_list ap;
va_start( ap, i );
A a = va_arg( ap, A ); // warning here
printf( "f(): i = %d, a.i = %d\n", i, a.i );
va_end(ap);
}
int
main( int, char *[] )
{
A b( 9 );
f( 8, b ); // warning here
return 0;
}