Thread View: gnu.g++.bug
2 messages
2 total messages
Started by Bryan Boreham
Tue, 20 Jun 1989 20:01
Maybe a bug in G++ 1.35.1-.
Author: Bryan Boreham
Date: Tue, 20 Jun 1989 20:01
Date: Tue, 20 Jun 1989 20:01
62 lines
1880 bytes
1880 bytes
Here's the example:
extern "C" void printf(char *, ...);
class Point
{
public:
short x;
short y;
public:
Point(short xx, short yy)
{ x= xx; y= yy; }
friend Point operator- (Point p1, Point p2)
{ return Point(p1.x - p2.x, p1.y - p2.y); }
};
void foo (Point p)
{
printf("(%d, %d)\n", p.x, p.y);
}
main()
{
Point x(10,20);
Point y(30,40);
foo (x - y);
}
Now, it compiles just fine:
kewill% g++ -v testpt.C -o testpt
g++ version 1.35.1-
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 testpt.C /tmp/cca29165.cpp
GNU CPP version 1.35
/usr/local/lib/gcc-cc1plus /tmp/cca29165.cpp -quiet -dumpbase testpt.C -noreg -version -o /tmp/cca29165.s
GNU C++ version 1.35.1- (68k, MIT syntax) compiled by GNU C version 1.35.
as -mc68020 /tmp/cca29165.s -o testpt.o
/usr/local/lib/gcc-ld++ -o testpt -C /usr/local/lib/crt0+.o /lib/Mcrt1.o testpt.o -lg++ /usr/local/lib/gcc-gnulib -lc
But, it gets the answer wrong!
kewill% testpt
(0, 40)
Now, I looked through Stroustrup and libg++, and I only ever see such
operators declared as:
friend Point operator- (Point& p1, Point& p2)
that is, with references instead of structures passed. So maybe there
is some reason why the answer is wrong.
Nonetheless, I think it ought to work.
Say, isn't ET++ good at flushing out those bugs?
Bryan.
Re: Maybe a bug in G++ 1.35.1-.
Author: Tom Vijlbrief
Date: Wed, 21 Jun 1989 07:04
Date: Wed, 21 Jun 1989 07:04
14 lines
908 bytes
908 bytes
I mailed an almost identical bug report yesterday to Michael Tieman. A fix is to use -fno-defer-pop when compiling ! Tom =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 562 11 3769 ZG Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom ===============================================================================
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