This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

class ``implementation'' info not always generated...

This bug is in g++ 2.8.1 (Solaris) thru egcs-2.91.55 19980824 (NEXTSTEP)...

If you get the circumstances just right, the g++ compiler won't
generate the backup copies of inline functions and the other
information it ought to for the implementation of a class. To trigger
the bug, it seems that you need just the right combination of
template classes, non-template classes, constructors and virtual
base classes.

Here are some minimal (?) files to generate the errant behaviour:

--- thingy.h -----------------------------------------------------------
#pragma interface

typedef int Val;
template <typename Val>
struct BarVirtualBase {
  virtual void explode() = 0;

template <typename Val>
struct Bar : public BarVirtualBase<Val> {
  Val value;
  Bar(Val v) : value(v) { };
  void explode () { }

#pragma implementation
#include "thingy.h"
--- -----------------------------------------------------------
#include "thingy.h"

struct Foo {
  Bar<int> tag;
  Foo(Foo* whatever);

inline Foo::Foo(Foo* whatever) : tag(0) {}
inline Foo::Foo() : tag(0) {}
main () {
  Foo start;

If you compile this code, you get an unresolved reference at link time,

unix% c++ -c              
unix% c++ -o buggy thingy.o
/bin/ld: Undefined symbols:
collect2: ld returned 1 exit status

... but if you turn on the optimizer, the symptoms vanish:

unix% c++ -O -o buggy thingy.o

... however, it may be that the problem has just gone underground.

Thoughts, comments, patches etc. appreciated,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]