C1001 internal error - templates, regression from VC++ 6.0

A

Al Grant

VC++ .NET 7.1 gives me an internal error from this code.
It worked fine in VC++ 6.0 and other compilers.
Are there any patches/SP's available for the 7.1 compiler?

template<typename T> struct a { char d; T o; };
#define A(T) (sizeof(a<T>) - sizeof(T))
template<int N> struct AS { char x[N]; };
template<typename T> AS<A(T)> AF(T const &);
#define AE(E) sizeof(AF(E))
int main(int n, char **) { return AE(n); }
/* ends */
 
D

David Lowndes

VC++ .NET 7.1 gives me an internal error from this code.
It worked fine in VC++ 6.0 and other compilers.

FWIW, I can reproduce the ICE with 7.1, but it compiles cleanly with
the Whidbey compiler so it looks like MS have fixed this already - not
that that's much use to you at the minute!

If no one here comes up with a suggested work-around, I recommend that
you contact MS product support - they may be able to tell you how to
work around it, and if there isn't a work-around, there may be a fix
they can supply you with.

Dave
 
G

Graeme Prentice

VC++ .NET 7.1 gives me an internal error from this code.
It worked fine in VC++ 6.0 and other compilers.
Are there any patches/SP's available for the 7.1 compiler?

template<typename T> struct a { char d; T o; };
#define A(T) (sizeof(a<T>) - sizeof(T))
template<int N> struct AS { char x[N]; };
template<typename T> AS<A(T)> AF(T const &);
#define AE(E) sizeof(AF(E))
int main(int n, char **) { return AE(n); }
/* ends */


Try this as a replacement for the A macro - it works for me.

template <typename T>
struct gs
{
static const size_t ret = sizeof (T);
};


#define A(T) ( gs< a<T> >::ret - gs<T>::ret)


Graeme
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top