🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1484

Argument passing bug in gcc-2.3.1 (sparc)

#1484
From: Christos Zoulas
Date: Tue, 24 Nov 1992 01:25
67 lines
1999 bytes
Hello,

The following program works correctly with sun's cc, but produces incorrect
results with gcc.

% cc bug.c
% a.out
 0 0 1.2 1.2 1 0

% gcc -v bug.c
Reading specs from /usr/local/lib/gcc-lib/sparc/2.3.1/specs
gcc version 2.3.1
 /usr/local/lib/gcc-lib/sparc/2.3.1/cpp -lang-c -v -undef -D__GNUC__=2 -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug.c /usr/tmp/cca03859.i
GNU CPP version 2.3.1 (sparc)
 /usr/local/lib/gcc-lib/sparc/2.3.1/cc1 /usr/tmp/cca03859.i -quiet -dumpbase bug.c -version -o /usr/tmp/cca03859.s
GNU C version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
 as -o /usr/tmp/cca038591.o /usr/tmp/cca03859.s
 /usr/local/lib/gcc-lib/sparc/2.3.1/ld -e start -dc -dp /lib/crt0.o -L/usr/local/lib/gcc-lib/sparc/2.3.1 -L/usr/local/lib /usr/tmp/cca038591.o -lgcc -lc -lgcc
% a.out
 0 0 4.24399e-315 1.2 1 0

% cat bug.c
#include <stdio.h>


struct x {
   struct {
	double b;
	double a;
   } q;
   struct {
	double m;
   } p;
   double nl;
   double lo;
   double in;
};


double f1(ip, d1, d2, d3)
   struct x *ip;
   double d1, d2, d3;
{
   return (d1 + 1.0) * d2 + d3 + 1.2;
}


double f2(d1, d2)
   double d1, d2;
{
   return d1 * d2 + 1.0;
}

struct x g;

main()
{
  struct x *ip = &g;

  (void)fprintf(stderr, " %g %g %g %g %g %.10g\n",
                ip->q.b, ip->q.a,
                f1(ip, 0.0, ip->p.m, 0.0),
                f1(ip, ip->p.m, 0.0, 0.0),
                f2(ip->nl, ip->lo),
                ip->in);
  exit(0);
}
Technical Details
Message-ID: <By75B7.144@deshaw.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!deshaw.com!christos

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!deshaw.com!christos
From: christos@deshaw.com (Christos Zoulas)
Subject: Argument passing bug in gcc-2.3.1 (sparc)
Message-ID: <By75B7.144@deshaw.com>
Keywords: sparc, arguments, double
Sender: gnulists@ai.mit.edu
Organization: D. E. Shaw & Co.
Distribution: gnu
Date: Tue, 24 Nov 1992 01:25:54 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 69