Web lists-archives.org

Re: [Mingw-users] [BUG] - member is template<T>: ice in 4.2.1-sjlj(mingw32-2), bad compilation in 3.4.5




> Hello all,
> 
> 
> The problem seems to be related to having a member whose type is
> template<T>. The AutoCounter class is used to track creation and
> deletion of objects.
> 
> AutoCounter was not originally a template. The exercise is to turn it
> into a template so that you can add a member to class T with type
> AutoCounter<T>, so that its messages will have the parent type name
> instead of "AutoCounter", e.g, "All MyType objects not cleaned up".
> 
> Compilation with gcc 3.4.5 is successful, but it crashes on the line:
> 
> verifier.add(this); // first line in AutoCounter();
> If I comment out this line, the program will run, but the output
> will be wrong.
> 
> If I compile with gcc-4.2.1-sjlj, I get an ICE:
> 
> c:\mingw4\bin\g++ -g -frtti -o test test.cpp
> 
> test.cpp: In destructor 'AutoCounter<T>::~AutoCounter() [with 
> T = Outer]':
> test.cpp:53:   instantiated from 
> 'AutoCounter<Outer>::CleanupCheck AutoCounter<O
> uter>::verifier'
> test.cpp:53:   instantiated from 
> 'AutoCounter<T>::~AutoCounter() [with T = Outer
> ]'
> test.cpp:76:   instantiated from here
> test.cpp:53: internal compiler error: in instantiate_decl, at 
> cp/pt.c:12094

I think the ICE is an error recovery problems.  This is what GCC trunk
says:

test.cpp:88: error: template arguments to 'AutoCounter<Outer>::verifier'
do not match original template 'AutoCounter<T>::verifier'
testspp :88: note: use template<> for an explicit specialization.

Danny


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users