471,123 Members | 887 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

C++/CLI: "Equals" as enum class member causes C1060

/*
(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::GreaterTha n);
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;
}
Oct 4 '06 #1
2 2012
"Phil Davidson" <Ph**@PhilDavidson.comwrote in message
news:ck********************************@4ax.com...
/*
(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?
I'd suggest posting a bug report for this - anything that causes unbounded
recursion in the compiler (which is likely what happened) is definitely a
bug, regardless of the language spec.

http://connect.microsoft.com/feedbac...spx?SiteID=210

-cd
Oct 4 '06 #2

"Phil Davidson" <Ph**@PhilDavidson.comwrote in message
news:ck********************************@4ax.com...
/*
(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) {
Internal compiler error should be reported to MS like Carl said.

With an eye toward fixing your code, though, an enum class is a value type,
and therefore you can, and usually should, use it without the tracking
reference (^).
Oct 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by D E | last post: by
21 posts views Thread by Helge Jensen | last post: by
reply views Thread by Klaus Löffelmann | last post: by
6 posts views Thread by Edward Diener | last post: by
12 posts views Thread by Howard Swope | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.