bug in egcs-1.1b on i586-linux
Vasilis Samoladas
vsam@cs.utexas.edu
Sun Nov 22 06:15:00 GMT 1998
Hi all. I am submitting the following bug. Just cut the rest of the
message and save it to file bugtst.cc. Instructions are contained in
the comments.
------------ CUT HERE -------------------
// Bug report
// ===========
// This program exposes a bug in egcs-1.1b when compiling with -O, on
// a Rredhat-5.0-i586 linux system.
//
// The problem is that methods of local classes (not in global scope)
// will not have code produced for them. This error is caught
// by the linker. A peculiarity of this bug is that it is only observed
// for local classes which inherit from some other (global) class.
//
//
// Versions:
// % /opt/bin/g++ -v
// Reading specs from /opt/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.57/specs
// gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
// % ld -v
// GNU ld version 2.9.1 (with BFD 2.9.1.0.15)
// Bug:
// % /opt/bin/g++ -O2 -o bugtst bugtst.cc
// /tmp/ccB0f01X.o(.gnu.linkonce.d.__vt_Q26main.0_9TEMPclass+0x8): undefined reference to `get__CQ26main.0_9TEMPclass.287'
// collect2: ld returned 1 exit status
// Notice1: It only appears with optimizations on.
// % /opt/bin/g++ -o bugtst bugtst.cc
// % # all OK!!
// Notice2: g++ 2.8.0 does not have this bug.
// ---------- example program --------------------
// -*- c++ -*- File: bugtst.cc
#include <iostream.h>
// This is a base class for GLOBclass and TEMPclass
class baseclass {
public:
virtual int get() const=0;
};
// This is a global class which only implements get()
class GLOBclass : public baseclass {
int i;
public:
GLOBclass(int _i) : i(_i) { };
int get() const { return i; };
};
int main()
{
// This is a local class which only implements get(), identical
// to GLOBclass
class TEMPclass
// if the next line is commented out, there is no problem
: public baseclass
{
int i;
public:
TEMPclass(int _i) : i(_i) { };
int get() const { return i; };
};
cout << TEMPclass(1).get() << endl;
cout << GLOBclass(2).get() << endl;
}
// ---------- end example program --------------------
// output of nm on bugtst.cc, compiled with
// /opt/bin/g++ -O2 -c bugtst.cc
// % nm bugtst.o
// 00000000 ? .LFB3
// 00000000 ? .LFB4
// 00000000 ? .LFB5
// 00000000 ? .LFB6
// 00000030 ? .LFE3
// 00000030 ? .LFE5
// 00000026 ? .LFE6
// 00000000 ? __FRAME_BEGIN__
// 00000000 t __Q26main.0_9TEMPclassi.286
// U __ls__7ostreami
// U __rtti_si
// U __rtti_user
// 00000000 W __tf9GLOBclass
// 00000000 W __tf9baseclass
// 00000000 W __tfQ26main.0_9TEMPclass
// U __throw
// 0000000c C __ti9GLOBclass
// 00000008 C __ti9baseclass
// 0000000c C __tiQ26main.0_9TEMPclass
// 00000000 W __vt_9GLOBclass
// 00000000 W __vt_Q26main.0_9TEMPclass
// U cout
// U endl__FR7ostream
// 00000000 t gcc2_compiled.
// 00000000 W get__C9GLOBclass
// U get__CQ26main.0_9TEMPclass.287
// 00000018 T main
More information about the Gcc-bugs
mailing list