public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/18742] New: small struct not passed correctly as vararg
Date: Tue, 30 Nov 2004 17:12:00 -0000	[thread overview]
Message-ID: <20041130171205.18742.lindig@cs.uni-sb.de> (raw)


	The following code tests that complex values are passed
        correctly. A value received by the callee is tested component by
        component to be equal with the (global) value that was passed.
        This fails for the  struct of type at2 that is passed as a var arg.

    failed in foo.c: 43
    failed in foo.c: 44

Environment:
System: Darwin jonagold.local 7.6.0 Darwin Kernel Version 7.6.0: Sun Oct 10 12:05:27 PDT 2004; root:xnu/xnu-517.9.4.obj~1/RELEASE_PPC Power Macintosh powerpc


	
host: powerpc-apple-darwin7.6.0
build: powerpc-apple-darwin7.6.0
target: powerpc-apple-darwin7.6.0
configured with: ../gcc/configure --prefix=/scratch/lindig --enable-languages=c : (reconfigured) ../gcc/configure --prefix=/scratch/lindig --enable-languages=c

How-To-Repeat:
    
    Compile and run the following code.


# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"



# 1 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/include/stdarg.h" 1 3 4
# 43 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 105 "/scratch/lindig/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
# 5 "foo.c" 2
extern int printf (char *, ...);

static int errors = 0;

static void failed( int line )
{ printf ("failed in %s: %d\n", "foo.c", line); errors++; }

static unsigned long int *av2 = (unsigned long int *) 361451618U;

static struct bt2 { float fv2; } kv2 = { 3984.018652 };

static
struct dt2
{ char gv2; struct ct2 { unsigned char hv2; unsigned char iv2; } jv2; }
lv2
=
    { '\x4f', { '\x27', '\x20' } };

static struct at2 { short int bv2; char cv2; } dv2 = { 14855, '\x3d' };

static double ev2 = 67318.083071;

static unsigned long int * callee_af2( struct bt2 ap2, struct dt2 bp2, ... )
{
    va_list ap;
    struct at2 mv2;
    double nv2;
    __builtin_va_start(ap,bp2);
    if (kv2.fv2 != ap2.fv2) failed (33);
    if (lv2.gv2 != bp2.gv2) failed (34);
    if (lv2.jv2.hv2 != bp2.jv2.hv2) failed (35);
    if (lv2.jv2.iv2 != bp2.jv2.iv2) failed (36);
    mv2 = __builtin_va_arg(ap,struct at2);
    nv2 = __builtin_va_arg(ap,double);
    if (mv2.bv2 != dv2.bv2) failed (39);
    if (mv2.cv2 != dv2.cv2) failed (40);
    if (nv2 != ev2) failed (41);
    __builtin_va_end(ap);
    return av2;
}

static void caller_bf2( )
{
    unsigned long int *ov2;
    ov2 = callee_af2 (kv2, lv2, dv2, ev2); if (av2 != ov2) failed (49);
}

int main( int argc, char **argv )
{ caller_bf2 (); return errors; }
------- Additional Comments From lindig at cs dot uni-sb dot de  2004-11-30 17:12 -------
Fix:
	No fix known.

-- 
           Summary: small struct not passed correctly as vararg
           Product: gcc
           Version: 0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lindig at cs dot uni-sb dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.6.0
  GCC host triplet: powerpc-apple-darwin7.6.0
GCC target triplet: powerpc-apple-darwin7.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18742


             reply	other threads:[~2004-11-30 17:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-30 17:12 gcc-bugzilla at gcc dot gnu dot org [this message]
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
2005-01-10 15:47 ` dje at gcc dot gnu dot org
2005-01-10 19:18 ` pinskia 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=20041130171205.18742.lindig@cs.uni-sb.de \
    --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).