This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/18742] small struct not passed correctly as vararg
- From: "chli002 at rz dot uni-saarland dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Jan 2005 15:32:24 -0000
- Subject: [Bug target/18742] small struct not passed correctly as vararg
- References: <20041130171205.18742.lindig@cs.uni-sb.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From chli002 at rz dot uni-saarland dot de 2005-01-10 15:32 -------
I have found similar cases; it appears that the crucial part is a {short;char} struct or union which is
passed as a var arg. Here is a similar program, somewhat smaller and with easier to understand names.
Again, on MacOS X 10.3 with gcc version 3.3 20030304:
$ ./foo
foo.c:17: failed assertion `y.f == i.f'
Abort trap
#include <stdarg.h>
#include <assert.h>
union A { float a; double b; } c = { 52.54 };
struct B { double d; unsigned int e; } h = { 78.01, 834U };
union C { short int f; char g; } i = { 68 };
struct D { char j; double k; } n = { 'c', 31.01 };
struct E { long long int l; double m; } o = { 167L, 17.2 };
union A callee( struct D a, struct E b, ... )
{
va_list ap;
struct B x;
union C y;
va_start (ap, b);
x = va_arg (ap, struct B);
y = va_arg (ap, union C);
assert (y.f == i.f);
va_end (ap);
return c;
}
int main( int argc, char **arg ) {
union A r;
r = callee (n, o, h, i);
assert (c.a == r.a);
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18742