This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc version 2.96 20000501, ICE 20000422 <memory>
- To: bug-gcc at gnu dot org
- Subject: gcc version 2.96 20000501, ICE 20000422 <memory>
- From: Peter Nordlund <peter dot nordlund at lentus dot se>
- Date: Mon, 08 May 2000 08:45:26 +0200
Hi there,
Thise code passes g++ 2000-04-02 but crashes with gcc version 2.96
20000501.
The code passes with
g++ bug.cpp
but not with
g++ -O bug.cpp
...
...
/home/petern/gcc/install/gcc/2000-05-01/include/g++-3/memory: In
instantiation of `auto_ptr<_Tp>::auto_ptr (int) [with _Tp =
WillBecomeSingleton]':
bug.cpp:62: instantiated from `ManagedSingleton::InstanceManager<T,
ManagedSingleton::CleanupMgr>::instance () [with T =
WillBecomeSingleton]'
bug.cpp:99: instantiated from here
/home/petern/gcc/install/gcc/2000-05-01/include/g++-3/memory:55:
Internal compiler error 20000422.
/home/petern/gcc/install/gcc/2000-05-01/include/g++-3/memory:55: Please
submit a full bug report.
...
...
--------------
>>uname -a
Linux petern 2.2.12-20 #2 Wed Apr 12 15:49:41 CEST 2000 i686 unknown
>g++ -v
Reading specs from
/home/petern/gcc/install/gcc/2000-05-01/bin/../lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 20000501 (experimental)
Se also attached temp-files.
//Peter
-----------------------
//bug.cpp
#define GCC_EXPLICIT_TEMPLATE_SELECTION_BUG
namespace ManagedSingleton {
template <typename T /* Singleton type */, typename MANAGER>
class Singleton {
public:
typedef MANAGER ManagerType;
typedef T SingletonType;
inline static T& instance(); //>x
inline static const T& constInstance(); //>x
protected:
Singleton() { }; // NOTHROW
~Singleton() { }; // NOTHROW
private:
Singleton(const Singleton&); // Shouldn't be used
Singleton& operator=(const Singleton&); // Shouldn't be used
};
// Singleton Adapter class. Will "convert" a class T into a Singleton.
template <typename T, typename MANAGER>
struct SingletonAdapter: public Singleton<T, MANAGER> { };
// Master template, should never be used.
// This class will manage the individual Singletons.
// A Manager class will exploit this class when managing
// all Singletons as a collection.
template <typename T, typename MANAGER>
class InstanceManager{};
/////////////////////////////////////////////////////////
// Implementations
//
template <typename T, typename MANAGER>
inline T& Singleton<T, MANAGER>::instance() {
return MANAGER::
#ifdef GCC_EXPLICIT_TEMPLATE_SELECTION_BUG
// Patch "template" should not be needed on line below.
template
#endif
instance<T>(); //>x
}
template <typename T, typename MANAGER>
inline const T& Singleton<T, MANAGER>::constInstance() { return
instance(); }
}; // namespace ManagedSingleton
//-------------------------------
#include <memory>
namespace ManagedSingleton {
struct CleanupMgr {
template <typename T> static T& instance() {
return InstanceManager<T, CleanupMgr>::instance(); //>x
}
};
template <typename T>
class InstanceManager<T, CleanupMgr> {
friend class CleanupMgr;
static T& instance() {
static std::auto_ptr<T> instance_(new T); //>x
return *instance_.get(); // NOTHROW
}
};
}; // namespace ManagedSingleton
//---------------------------------
#define SIMPLE_CLEANUP_MGR
#include <iostream>
#include <exception> // For terminate
typedef ManagedSingleton::CleanupMgr Mgr;
using namespace ManagedSingleton;
class WillBecomeSingleton {
template <typename DS, typename MGR2> friend class InstanceManager;
friend class std::auto_ptr<WillBecomeSingleton>; // Not the best
solution, but simple ...
public:
typedef int CountType;
void print() const throw() { std::cerr <<
"WillBecomeSingleton.print()" << std::endl; }
int testFunction() throw(const char*) {
throw "Simulate failure in WillBecomeSingleton::testFunction()";
return 1;
}
private:
WillBecomeSingleton() throw(const char*){
std::cerr << "WillBecomeSingleton" << std::endl;
}
~WillBecomeSingleton() throw() { std::cerr << "~WillBecomeSingleton"
<< std::endl; }
};
typedef SingletonAdapter<WillBecomeSingleton, Mgr> AdaptedSingleton;
int main(int argc, const char** argv){
AdaptedSingleton::instance();
return 0;
}
bug.tgz