🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Christos Zoulas Tue, 24 Nov 1992 01:25
Argument passing bug in gcc-2.3.1 (sparc)
#1484
Author: 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);
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads