public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "chli002 at rz dot uni-saarland dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/18742] small struct not passed correctly as vararg
Date: Mon, 10 Jan 2005 15:32:00 -0000	[thread overview]
Message-ID: <20050110153224.5127.qmail@sourceware.org> (raw)
In-Reply-To: <20041130171205.18742.lindig@cs.uni-sb.de>


------- 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


  parent reply	other threads:[~2005-01-10 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-30 17:12 [Bug c/18742] New: " gcc-bugzilla at gcc dot gnu dot org
2004-11-30 17:26 ` [Bug target/18742] " pinskia at gcc dot gnu dot org
2005-01-10 15:32 ` chli002 at rz dot uni-saarland dot de [this message]
2005-01-10 15:47 ` dje at gcc dot gnu dot org
2005-01-10 19:18 ` pinskia at gcc dot gnu dot org
     [not found] <bug-18742-9042@http.gcc.gnu.org/bugzilla/>
2010-07-24  8:08 ` iains at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050110153224.5127.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).