Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Robert Collins
Wed, 06 Dec 1989 00:35
g++-1.36.2- -O bug
Author: Robert Collins
Date: Wed, 06 Dec 1989 00:35
Date: Wed, 06 Dec 1989 00:35
94 lines
3180 bytes
3180 bytes
Michael,
This one was buried in 10,000 lines of code...what a pain to find...
Sun4/330 SunOS 4.0.3
Incorrect results are generated in the following program when compiled
with -O. Here is a copy of the source file, compiled and run with -O,
and compiled and run without -O.
Have fun,
rob
rjc@cs.ucla.edu
Script started on Tue Dec 5 16:27:23 1989
castor.cognet.ucla.edu% cat foo.cc
#include <assert.h>
unsigned builtin_alg = 1;
unsigned num_algs = 3;
unsigned alg1_initial_food(const unsigned gen)
{
unsigned amount = 1;
#if 0
if ((rng->asLong() % 300) == 0) {
amount = (rng->asLong() % 500) + 1;
};
#endif
return amount;
}
unsigned net_initial_food(const unsigned gen)
{
return 0;
}
unsigned alg2_initial_food(const unsigned gen)
{
return 0;
}
unsigned initial_food(const unsigned gen) return
amount()
{
assert(builtin_alg < num_algs);
switch (builtin_alg) {
case 0:
amount = net_initial_food(gen);
break;
case 1:
amount = alg1_initial_food(gen);
break;
case 2:
amount = alg2_initial_food(gen);
break;
default:
assert(0);
break;
};
return /* amount */;
}
main()
{
assert(initial_food(0) == 1);
}
castor.cognet.ucla.edu% g++ -v -O foo.cc
g++ version 1.36.2- (based on GCC 1.36)
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ foo.cc /tmp/cca12490.cpp
GNU CPP version 1.36
/usr/local/lib/gcc-cc1plus /tmp/cca12490.cpp -quiet -dumpbase foo.cc -O -version -o /tmp/cca12490.s
GNU C++ version 1.36.2- (based on GCC 1.36) (sparc) compiled by GNU C version 1.36.
default target switches: -mfpu -mepilogue
/usr/local/lib/gcc-as -o foo.o /tmp/cca12490.s
/usr/local/lib/gcc-ld -e start -dc -dp /lib/crt0.o foo.o -lg++ /usr/local/lib/gcc-gnulib -lc
castor.cognet.ucla.edu% a.out
Failed assertion initial_food(0) == 1 at line 51 of `foo.cc'.
Abort (core dumped)
castor.cognet.ucla.edu% g++ -v foo.cc
g++ version 1.36.2- (based on GCC 1.36)
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ foo.cc /tmp/cca12496.cpp
GNU CPP version 1.36
/usr/local/lib/gcc-cc1plus /tmp/cca12496.cpp -quiet -dumpbase foo.cc -version -o /tmp/cca12496.s
GNU C++ version 1.36.2- (based on GCC 1.36) (sparc) compiled by GNU C version 1.36.
default target switches: -mfpu -mepilogue
/usr/local/lib/gcc-as -o foo.o /tmp/cca12496.s
/usr/local/lib/gcc-ld -e start -dc -dp /lib/crt0.o foo.o -lg++ /usr/local/lib/gcc-gnulib -lc
castor.cognet.ucla.edu% a.out
castor.cognet.ucla.edu% ^D
script done on Tue Dec 5 16:27:55 1989
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