Re: Member template internal compiler error

Tech-Archive recommends: Fix windows errors by optimizing your registry



Kristo wrote:
I am getting an Internal Compiler Error in VC++ 6 with the following code. I'm fairly sure it is well-formed (g++ 3.4.2 compiles it fine). Is there a workaround available?

#include <iostream>
#include <ostream>

class Foo
{
public:
    template <int N>
    static void Test()
    {
        std::cout << N << std::endl;
    }
};

int main()
{
    Foo::Test<5>();  /* I.C.E. here */
}

VC++ v6 is notoriously bad with templates. You'll be much better off when you upgrade to the later compiler (7.1 is currently shipping). For now, if you can, make this static member non-member but a simple free-standing function template.

V
.



Relevant Pages

  • Re: Template instantiation issue
    ... I was hoping someone could help, I have some code that compiles on GCC but throws a warning with VS2005. ... TY polFit(const TX&,const int, ... confused about that (the const is redundant for the declaration in any case). ... template double polFit(const double&,const int, ...
    (microsoft.public.vc.language)
  • Re: Can this conversion code be simplified?
    ... Joe Wright wrote: ... Now I need each byte as an int. ... It compiles cleanly and produces the following output: ...
    (comp.lang.c)
  • Re: 2 variable "nested" loop with TMP
    ... static void apply ... template< int M, int N, int I> ... struct loop< M, N, I, 0> ...
    (comp.lang.cpp)
  • Re: template class and static function pointer.
    ... static void; ... template <int tt> ... but it's not compiler in VC7.1! ...
    (microsoft.public.vc.mfc)
  • Re: Is this valid ISO C++?
    ... > This compiles with MINGW GCC 3.4.2 but not with my other compilers. ... > inline void test(const ValueType &val) ... > int main ... this is not valid for a simple reason that std::vector is a template ...
    (comp.lang.cpp)