template/STL interaction
D Maley
d.maley@airforce1.stmarys-belfast.ac.uk
Mon Sep 28 11:29:00 GMT 1998
Hi,
I'm encountering problems trying to compile code under egcs1.1 that compiled
OK under 1.0.2. My system does calculations in Computational Physics, but
I've tried to throw out as many specifics as I can and isolate the problem.
The constructs may look weird, but I think they're legal.
Number One.
#include <pair.h>
template <class T> class Composite2 : public pair<typename T::first_type,
typename T::second_type> {
public:
Composite2() : pair() {}
Composite2(typename T::first_type, typename T::second_type);
};
/////////////////////////////////////////////////////////////
//
// Commencing 'Help-the-Compiler' Section
//
template class pair<int, float>;
template class Composite2<pair<int, float> >;
//
// End of Compiler Assistance Section
//
/////////////////////////////////////////////////////////////
template <class T> Composite2<T>::Composite2(typename T::first_type s,
typename T::second_type t) : pair<typename T::first_type, typename
T::second_type>(s, t) { }
gcc -DXTFUNCPROTO -DSUN -w -frepo -I/usr/openwin/include
-I/usr/dt/share/include -I. -c -o bug.o bug.cpp 2>>err
*** Error code 1
make: Fatal error: Command failed for target `bug.o'
bug.cpp: In method `Composite2<pair<int,float>
>::Composite2<pair<int,float>>()':
bug.cpp:14: instantiated from here
bug.cpp:5: Internal compiler error.
bug.cpp:5: Please submit a full bug report to `egcs-bugs@cygnus.com'.
Commenting out lines 6 & 20 yields:
gcc -DXTFUNCPROTO -DSUN -w -frepo -I/usr/openwin/include
-I/usr/dt/share/include -I. -c -o bug.o bug.cpp 2>>err
*** Error code 1
make: Fatal error: Command failed for target `bug.o'
bug.cpp: In method `Composite2<pair<int,float>
>::Composite2<pair<int,float>>()':
bug.cpp:14: instantiated from here
bug.cpp:5: type `pair<pair<int,float>,T2>' is not a base type for type
`Composite2<pair<int,float> >'
*/
Number Two.
File 1:
/////////////////////////////////////////////////////////////
//
// Composite.h
//
/////////////////////////////////////////////////////////////
#include <pair.h>
template <class S, class T> class Pair : public pair<S, T> {
public:
Pair();
Pair(S, T);
};
File 2:
/////////////////////////////////////////////////////////////
//
// Composite.cpp
//
/////////////////////////////////////////////////////////////
#pragma implementation "Composite.h"
#include "Composite.h"
/////////////////////////////////////////////////////////////
//
// Commencing 'Help-the-Compiler' Section
//
template class Pair<Pair<int, float>, double>;
//
// End of Compiler Assistance Section
//
/////////////////////////////////////////////////////////////
template <class S, class T> Pair<S, T>::Pair() : pair<S, T>() { }
template <class S, class T> Pair<S, T>::Pair(S s, T t) : pair<S, T>(s, t) { }
void main() {}
gcc -DXTFUNCPROTO -DSUN -w -falt-external-templates -I/usr/openwin/include
-I/usr/dt/share/include -I. -c -o Composite.o Composite.cpp 2>>err
*** Error code 1
make: Fatal error: Command failed for target `Composite.o'
/usr/local/include/g++/stl_pair.h: In method
`pair<Pair<int,float>,double>::pair<int, float>(const struct pair<int,float>
&)':
Composite.cpp:25: instantiated from here
/usr/local/include/g++/stl_pair.h:48: no matching function for call to
`Pair<int,float>::Pair (const int &)'
Composite.cpp:16: candidates are: Pair<int,float>::Pair(const Pair<int,float> &)
Composite.cpp:23: Pair<int,float>::Pair<int, float>()
Composite.cpp:25: Pair<int,float>::Pair<int, float>(int, float)
I don't know where "pair<Pair<int,float>,double>::pair<int, float>" comes
from. I'm trying to move away from using -falt-external-templates, but its
been the only template options that's worked in the past. In this example,
if the code header file is actually placed in the source file, replacing the
#include, the code compiles, but that's no use when I scale up.
I don't know what comprises a full bug report, so I've just given you the
code and the messages. I'm on a P200 under Solaris 2.6.
--- |================================================|
---- |-=| Dave Maley, M.A., M.Phil. |=-| ,---I
--- |================================================| |== U-----
--- | Computer Manager, St. Mary's College, Belfast | |== U (: |
--- |________________________________________________| | U----'-----
----- |________________________________/ ____====______| U' ()___(|
--- #__ //,-, ,-, ,-,\\ \| ///,-, ,-, \\ -------/,-,\_[
''( 0 )( 0 )( 0 )' o -''( 0 )( 0 ) \\#####====( 0 )
--------------'-'--'-'--'-'-------------------'-'--'-'--------------'-'----
More information about the Gcc-bugs
mailing list