P
Phil Davidson
/*
(Posted to microsoft.public.dotnet.languages.vc)
In C++/CLI under Visual Studio 2005, creating an "enum class" member
called "Equals" can cause compiler error C1060 (out of memory) and C1063
(internal error). See the following example program, a CLR console app.
Of course the obvious workaround is to refrain from using "Equals". But
does that really violate the specification of the language or the CLR?
And can the compiler be changed to at least give an explicit warning,
and not slow to a snail's pace?
phil -at- ivorycc.com
*/
#include "stdafx.h"
using namespace System;
namespace Problem {
// It's the Equals member that makes us vulnerable to
// compiler errors C1060 and C1063 below.
public enum class Symbol { Equals, GreaterThan, LessThan };
ref class cl {
public:
static bool IsGreater(Symbol^ sym) {
// The following statement causes compiler errors C1060
// and C1063:
// if (sym->Equals(Symbol::GreaterThan))
if (sym == Symbol::GreaterThan) // This statement never
// reports equality.
{
return true;
}
return false;
}
};
};
int main(array<System::String ^> ^args)
{
bool bResult1 =
Problem::cl::IsGreater(Problem::Symbol::GreaterThan);
Console::WriteLine(L"bResult1 is " + bResult1 +
" and should be True");
bool bResult2 = Problem::cl::IsGreater(Problem::Symbol::LessThan);
Console::WriteLineL"bResult2 is " + bResult2 +
" and should be False");
Console::WriteLine(L"Press Enter to continue");
Console::ReadLine();
return 0;
}
(Posted to microsoft.public.dotnet.languages.vc)
In C++/CLI under Visual Studio 2005, creating an "enum class" member
called "Equals" can cause compiler error C1060 (out of memory) and C1063
(internal error). See the following example program, a CLR console app.
Of course the obvious workaround is to refrain from using "Equals". But
does that really violate the specification of the language or the CLR?
And can the compiler be changed to at least give an explicit warning,
and not slow to a snail's pace?
phil -at- ivorycc.com
*/
#include "stdafx.h"
using namespace System;
namespace Problem {
// It's the Equals member that makes us vulnerable to
// compiler errors C1060 and C1063 below.
public enum class Symbol { Equals, GreaterThan, LessThan };
ref class cl {
public:
static bool IsGreater(Symbol^ sym) {
// The following statement causes compiler errors C1060
// and C1063:
// if (sym->Equals(Symbol::GreaterThan))
if (sym == Symbol::GreaterThan) // This statement never
// reports equality.
{
return true;
}
return false;
}
};
};
int main(array<System::String ^> ^args)
{
bool bResult1 =
Problem::cl::IsGreater(Problem::Symbol::GreaterThan);
Console::WriteLine(L"bResult1 is " + bResult1 +
" and should be True");
bool bResult2 = Problem::cl::IsGreater(Problem::Symbol::LessThan);
Console::WriteLineL"bResult2 is " + bResult2 +
" and should be False");
Console::WriteLine(L"Press Enter to continue");
Console::ReadLine();
return 0;
}