public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/18742] New: small struct not passed correctly as vararg
@ 2004-11-30 17:12 gcc-bugzilla at gcc dot gnu dot org
  2004-11-30 17:26 ` [Bug target/18742] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-11-30 17:12 UTC (permalink / raw)
  To: gcc-bugs


	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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18742] small struct not passed correctly as vararg
  2004-11-30 17:12 [Bug c/18742] New: small struct not passed correctly as vararg gcc-bugzilla at gcc dot gnu dot org
@ 2004-11-30 17:26 ` pinskia at gcc dot gnu dot org
  2005-01-10 15:32 ` chli002 at rz dot uni-saarland dot de
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-30 17:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-30 17:26 -------
Confirmed.  Note also Apple's 3.3 and 3.1 also fails.  So does the FSF 3.3.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |target
     Ever Confirmed|                            |1
  GCC build triplet|powerpc-apple-darwin7.6.0   |
   GCC host triplet|powerpc-apple-darwin7.6.0   |
           Keywords|                            |ABI, wrong-code
      Known to fail|                            |3.3.2 4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-30 17:26:32
               date|                            |
            Version|0.0                         |4.0.0


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18742] small struct not passed correctly as vararg
  2004-11-30 17:12 [Bug c/18742] New: small struct not passed correctly as vararg 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
  2005-01-10 15:47 ` dje at gcc dot gnu dot org
  2005-01-10 19:18 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: chli002 at rz dot uni-saarland dot de @ 2005-01-10 15:32 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18742] small struct not passed correctly as vararg
  2004-11-30 17:12 [Bug c/18742] New: small struct not passed correctly as vararg 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
@ 2005-01-10 15:47 ` dje at gcc dot gnu dot org
  2005-01-10 19:18 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: dje at gcc dot gnu dot org @ 2005-01-10 15:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dje at gcc dot gnu dot org  2005-01-10 15:47 -------
The testcases work correctly on AIX and powerpc64-linux, so this likely is due
to Darwin not implementing consistent aggregate padding rules in GCC for
backward compatibility.

-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18742] small struct not passed correctly as vararg
  2004-11-30 17:12 [Bug c/18742] New: small struct not passed correctly as vararg gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2005-01-10 15:47 ` dje at gcc dot gnu dot org
@ 2005-01-10 19:18 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-10 19:18 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug target/18742] small struct not passed correctly as vararg
       [not found] <bug-18742-9042@http.gcc.gnu.org/bugzilla/>
@ 2010-07-24  8:08 ` iains at gcc dot gnu dot org
  0 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu dot org @ 2010-07-24  8:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from iains at gcc dot gnu dot org  2010-07-24 08:08 -------
fixed at least >= 4.4


-- 

iains at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-07-24  8:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-30 17:12 [Bug c/18742] New: small struct not passed correctly as vararg 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
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

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