Article View: gnu.g++.bug
Article #4731.36.0- violating segments
From: "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
Technical Details
Message-ID:
<8910042136.AA03733@gila.santafe.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!SFI.SANTAFE.EDU!scpShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!tut.cis.ohio-state.edu!SFI.SANTAFE.EDU!scp
From: scp@SFI.SANTAFE.EDU ("Stephen C. Pope")
Newsgroups: gnu.g++.bug
Subject: 1.36.0- violating segments
Message-ID: <8910042136.AA03733@gila.santafe.edu>
Date: 4 Oct 89 21:36:14 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 62