Thread View: gnu.g++.bug
1 messages
1 total messages
Started by "Stephen C. Pope"
Wed, 04 Oct 1989 21:36
1.36.0- violating segments
Author: "Stephen C. Pope"
Date: Wed, 04 Oct 1989 21:36
Date: Wed, 04 Oct 1989 21:36
62 lines
1992 bytes
1992 bytes
I believe (though I'm not exactly sure) that I'm doing
something illegal with the const T& member flagged below.
In any case, g++`s output is behavior is not very helpful
(SparcStation, SunOS4.0.3c, this is the now-obsolete
g++.ytar.Z w/ patches. Could someone try it on the new 1.36.0-???)
gcc -v -O -fstrength-reduce -c t.cc
gcc version 1.36.0- (based on GCC 1.35.98+)
/usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ t.cc /tmp/cca03730.cpp
GNU CPP version 1.35.98
/usr/local/lib/gcc-cc1plus /tmp/cca03730.cpp -quiet -dumpbase t.cc -fstrength-reduce -O -version -o /tmp/cca03730.s
GNU C++ version 1.36.0- (based on GCC 1.35.98+) (sparc) compiled by GNU C version 1.35.98.
default target switches: -mfpu -mepilogue
t.cc: In method int TP::get_r ():
t.cc:19: Segmentation violation
gcc: Program cc1plus got fatal signal 11.
heres the code:
class T {
const int r;
public:
T(int);
int const get_r();
};
class TP {
const T& t; // legal???
public:
TP(int);
int get_r();
void do_something(int);
};
T::T(int i) : r(i) {}
inline int T::get_r() { return r; }
TP::TP(int i) : t(*(new T(i))) {}
inline int TP::get_r() { return t.get_r(); }
void TP::do_something(int i)
{
int a, b, c;
a = 0;
b = 1;
c = i * b + a;
}
main()
{
TP t(16);
int s = 0;
for( int i = 0; i < t.get_r(); ++i ) {
s += i;
t.do_something(s);
}
return s;
}
Stephen Pope
scp@sfi.santafe.edu
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