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]

egcs-1.0 bug: static members in template classes


There's a problem with static members in template classes still around.
It doesn't show up if I compile everything with -frepo, but someone
told me that this flag should not be needed with ELF...

-- 

[gloth@unknown]$ cat common.h
struct Foo {
    Foo (int);
};

template<class T>
struct Bar { };

template<class T>
struct Bat : Bar<T> {
    virtual Foo* bug();
    static Foo bug_; 
};

template<class T> Foo Bat<T>::bug_ (1);

template<class T> Foo *Bat<T>::bug() {
    return &Bat<T>::bug_;
}
[gloth@unknown]$ cat bar.cpp
#include "common.h"

Bat<int> bar;
[gloth@unknown]$ cat foo.c
#include "common.h"

Bat<int> foo;

[gloth@unknown]$ g++ -c bar.cpp
[gloth@unknown]$ g++ -c foo.cpp
[gloth@unknown]$ g++ -shared -o libfoo.o bar.o foo.o
foo.o(.bss+0x8): multiple definition of `Bat<int>::bug_'
bar.o(.bss+0x8): first defined here
collect2: ld returned 1 exit status

[gloth@unknown]$ g++ --version
egcs-2.90.21 971202 (egcs-1.00 release)

[gloth@unknown]$ config.guess
i586-pc-linux-gnu

-- 

Tobias Gloth    |  WWW:     http://wwwmath.uni-muenster.de/~gloth
Kuhstr. 13      |  work:    gloth@math.uni-muenster.de
48143 Muenster  |  private: gloth@unknown.westfalen.de


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