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]
Other format: [Raw text]

[Bug c++/34178] New: Compilation using -frepo fails


When compiling the following piece of code with "-frepo", linking fails


template<typename T>
class A
{
        private:
                static int x;

        public:
                int getX() { return x; }
};

template<typename T> int A<T>::x=0;

int main()
{
        A<int> a;
        a.getX();
}


g++  -frepo  -c -o test.o test.cpp
g++ -o test test.o
collect: recompiling test.cpp
collect: relinking
test.o: In function `A<int>::getX()':
test.cpp:(.text+0x4): undefined reference to `A<int>::x'
collect2: ld returned 1 exit status


I tested this with an unpatched gcc 4.3.0 20071012 and 4.1.2 with on Gentoo
Linux. 
gcc 3.4.6 compiles correctly. 

Probably the output of the .rpo-files is interesting:

gcc-3: 
M test.cpp
D /home/rbuergel/frepo-test
A '-frepo' '-c' '-o' 'test.o' '-march=i686'
C _ZN1AIiE1xE
O _ZN1AIiE4getXEv

gcc-4:
M test.cpp
D /home/rbuergel/frepo-test
A '-frepo' '-c' '-o' 'test.o' '-shared-libgcc' '-mtune=generic' '-march=i686'
'-frandom-seed=0x63d4762b' '-shared-libgcc'
C _ZN1AIiE4getXEv


gcc-4 gets it right, if x is just declared and defined, but not initialized.


-- 
           Summary: Compilation using -frepo fails
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rbuergel at web dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34178


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