Re: C1001 ICE with .NET 2003 compiling templates
From: tom_usenet (tom_usenet_at_hotmail.com)
Date: 03/23/04
- Next message: David Lowndes: "Re: Optimization bug in VC++ 6.0"
- Previous message: a.m.a: "Re: Tutorial/help for creating a LIB whithout dependencies ?"
- In reply to: Programmer_blabla: "C1001 ICE with .NET 2003 compiling templates"
- Next in thread: Andy Coates: "Re: C1001 ICE with .NET 2003 compiling templates"
- Reply: Andy Coates: "Re: C1001 ICE with .NET 2003 compiling templates"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 23 Mar 2004 17:44:16 +0000
On 23 Mar 2004 07:52:42 -0800, programmer_blabla@hotmail.com
(Programmer_blabla) wrote:
>Dear all,
>
>I have spent the whole day figuring out a weird error. In the end I
>could strip it down the following code snippet:
>
>template <typename T>
>struct NCTestPointerTraits
>{
>};
>
>
>template <typename T>
>struct NCTestPointerTraits<T*>
>{
> enum {eSize = sizeof(T)};
Note you can only use sizeof with complete types.
>};
>
>
>//leave other specializations...
>
>
>template <typename T>
>bool TestIsValidPointerExT(T* p, size_t nLen =
>NCTestPointerTraits<T*>::eSize)
>{
> //return NCDbgMemory::IsValidPointerEx(p, nLen);
> return true;
>}
>
>
>struct NCTestEmpty
>{
> NCTestEmpty()
> : m_p(NULL)
> {
> }
>
> ~NCTestEmpty()
> {
(Workaround - add here:
sizeof std::set<int>();)
> TestIsValidPointerExT(m_p); //<-- GIVES ICE
There seems to be a problem with VC7.1's implicit instantiation.
std::set<int> should be instantiated by the sizeof in
NCTestPointerTraits, but it isn't for some reason, and the compiler is
going mad.
>Using a map instead of set, one gets weird compiler errors. The set
>gives an ICE, but the member m_p1(no STL or template) is accepted. Is
>this legal C++, or is the compiler confused? Be aware that the pointer
>must be declared as a member, just an ordinary local variable is
>accepted.
The workaround above gets rid of the error, but it is a bug of course
- the code is legal (once you add the necessary #includes).
Tom
-- C++ FAQ: http://www.parashift.com/c++-faq-lite/ C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
- Next message: David Lowndes: "Re: Optimization bug in VC++ 6.0"
- Previous message: a.m.a: "Re: Tutorial/help for creating a LIB whithout dependencies ?"
- In reply to: Programmer_blabla: "C1001 ICE with .NET 2003 compiling templates"
- Next in thread: Andy Coates: "Re: C1001 ICE with .NET 2003 compiling templates"
- Reply: Andy Coates: "Re: C1001 ICE with .NET 2003 compiling templates"
- Messages sorted by: [ date ] [ thread ]