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]

Repo mechanism worse than in version 2.7.2


Hi,

(I have looked in deja news and in the common bugs section on www.gnu.org and
have been unable to find any information on this problem)

I have recently upgraded from gcc 2.7.2 to gcc 2.95.2 on multiple platforms
(Solaris 2.5.1, AIX 4.3.2, HP-UX 10.20, Tru64 4.0d, + more) and am having
a problem with different behaviour between the new and the old repo
mechanism.

The problem is the repo mechanism does not instantiate as many symbols during
the recompilation step.

Using gcc 2.7.2 with the repo patch, templates had a chance of being
instantiated without an explicit "template void x<int>::func()" line. The rule
appeared to be that if a class used an explicitly typed template, then that
class (with its type(s)) would be added to the list of possible instantiations.

The new behaviour is that every class has to be explicitly listed before it
will be instantiated.


To reproduce the problem, I compiled the following code:
=========== Makefile start ============
CC=gcc

main: main.o secondclass.o templates.o
        $(CC) -o main -frepo main.o secondclass.o templates.o

templates.o: templates.cc
        $(CC) -frepo -c templates.cc

main.o: main.cc
        $(CC) -fno-implicit-templates -c main.cc

secondclass.o: secondclass.cc
        $(CC) -fno-implicit-templates -c secondclass.cc

clean:
        rm -f main *.*o
=========== Makefile end ============
=========== firstclass.cc start ============
template <class T> T firstclass<T>::method() {
  return val;
}
=========== firstclass.cc end ============
=========== firstclass.h start ============
template <class T> class firstclass {
public:
  T val;
  firstclass(T newval) : val(newval) {}
  T method();
};
=========== firstclass.h end ============
=========== main.cc start ============
#include "firstclass.h"
#include "secondclass.h"

int main(int,char*[])
{
  secondclass a(2);
  return 1;
}
=========== main.cc end ============
=========== secondclass.cc start ============
#include "firstclass.h"
#include "secondclass.h"

secondclass::secondclass(int newval) : first(newval)
{
  first.method();
}
=========== secondclass.cc end ============
=========== secondclass.h start ============
class secondclass {
public:
  firstclass<int> first;
  secondclass(int newval);
};
=========== secondclass.h end ============
=========== templates.cc start ============
#include "firstclass.h"
#include "secondclass.h"
#include "firstclass.cc"
=========== templates.cc end ============

When compiling with 2.7.2+repo, I get
muck duncans ~/gcctest > gcc --version
2.7.2
muck duncans ~/gcctest > make
        gcc -fno-implicit-templates -c main.cc
        gcc -fno-implicit-templates -c secondclass.cc
        gcc -frepo -c templates.cc
        gcc -o main -frepo main.o secondclass.o templates.o
collect: recompiling templates.cc
collect: relinking
muck duncans ~/gcctest > 

with gcc 2.95.2, I get
muck duncans ~/gcctest > egcc --version
2.95.2
muck duncans ~/gcctest > make
        egcc -fno-implicit-templates -c main.cc
        egcc -fno-implicit-templates -c secondclass.cc
        egcc -frepo -c templates.cc
        egcc -o main -frepo main.o secondclass.o templates.o
Undefined                       first referenced
 symbol                             in file
firstclass<int>::method(void)       secondclass.o
UX:ld: ERROR: main: fatal error: Symbol referencing errors. No output written to main
collect2: ld returned 1 exit status
*** Error code 1 (bu21)
UX:make: ERROR: fatal error.
muck duncans ~/gcctest > 


Is this a bug?
Is there any plan to alter this behaviour?
If so what kind of timescale is it likely to happen in?
Is it possible to use the output from the linker to instantiate extra object
code (The repo mechanism has the code, why can't it instantiate the function?)?


Thanks for any response you send me, and the time you have spent on the
product.

Duncan
 ________________________________________________________________________
| Duncan Stansfield        Vision Park    Email: duncans@sco.com         |
|                          Cambridge      Tel: +44 1223 518054           |
| Software Engineer        CB4 4ZR        Fax: +44 1223 518001           |
| SCO Cambridge            England        WWW: http://tarantella.sco.com |
 ------------------------------------------------------------------------

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