This is the mail archive of the gcc-bugs@gcc.gnu.org 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 -----------------------------------------------------------
#ifndef THING_H_INCLUDED
#define THING_H_INCLUDED
#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 () { }
};

#endif // THING_H_INCLUDED
--- thingy.cc-----------------------------------------------------------
#pragma implementation
#include "thingy.h"
--- buggy.cc -----------------------------------------------------------
#include "thingy.h"

struct Foo {
  Bar<int> tag;
  Foo();
  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,
thus:

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

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

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

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

Thoughts, comments, patches etc. appreciated,

    Melissa.


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