E
Emil Dotchevski
This code causes the compiler to allocade a *lot* of memory *very*
fast, and even when I hit ctrl+break it still takes about a minute for
my system to recover and start responding to user input again.
What is more strange is the workarounds that prevent this compiler bug
from occuring.
For example, making the 'l' object a type (by adding a typedef at the
beginning of the last line) inhibits the bug.
Giving a name to the nameless namespace that contains the c1, c2, c3
and c4 classes also inhibits the problem.
So does removing the const modifier of c2 (!) in the last line.
I hope these clues will help fixing the issue. A friend of mine from
Microsoft also tried this code on the new 8.0 compiler and reported
that it causes the same issues.
<c++>
struct nil;
template <class T,class U=nil>
struct cons
{
typedef T head;
typedef U tail;
};
template <class T,class L>
struct cut_list
{
typedef cons<T,typename cut_list<typename L::head,typename
L::tail>::list > list;
};
template <class L>
struct cut_list<nil,L>
{
typedef nil list;
};
template <
class T1=nil,
class T2=nil,
class T3=nil,
class T4=nil,
class T5=nil,
class T6=nil>
struct makelist
{
typedef typename
cut_list<T1,
cons<T2,
cons<T3,
cons<T4,
cons<T5,
cons<T6};
namespace
{
class c1;
class c2;
class c3;
class c4;
}
makelist<c1 const,c2 const,c3 const,c4 const> l;
//Some workarounds that (individually) inhibit the bug (replace the
line above)
//typedef makelist<c1 const,c2 const,c3 const,c4 const> l;
//makelist<c1 const,c2,c3 const,c4 const> l;
</c++>
fast, and even when I hit ctrl+break it still takes about a minute for
my system to recover and start responding to user input again.
What is more strange is the workarounds that prevent this compiler bug
from occuring.
For example, making the 'l' object a type (by adding a typedef at the
beginning of the last line) inhibits the bug.
Giving a name to the nameless namespace that contains the c1, c2, c3
and c4 classes also inhibits the problem.
So does removing the const modifier of c2 (!) in the last line.
I hope these clues will help fixing the issue. A friend of mine from
Microsoft also tried this code on the new 8.0 compiler and reported
that it causes the same issues.
<c++>
struct nil;
template <class T,class U=nil>
struct cons
{
typedef T head;
typedef U tail;
};
template <class T,class L>
struct cut_list
{
typedef cons<T,typename cut_list<typename L::head,typename
L::tail>::list > list;
};
template <class L>
struct cut_list<nil,L>
{
typedef nil list;
};
template <
class T1=nil,
class T2=nil,
class T3=nil,
class T4=nil,
class T5=nil,
class T6=nil>
struct makelist
{
typedef typename
cut_list<T1,
cons<T2,
cons<T3,
cons<T4,
cons<T5,
cons<T6};
namespace
{
class c1;
class c2;
class c3;
class c4;
}
makelist<c1 const,c2 const,c3 const,c4 const> l;
//Some workarounds that (individually) inhibit the bug (replace the
line above)
//typedef makelist<c1 const,c2 const,c3 const,c4 const> l;
//makelist<c1 const,c2,c3 const,c4 const> l;
</c++>