473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 2155
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: D E | last post by:
Ok the subject line is basically the question. Obviously this won't work. What is the technical reason? Is it because here, "test1" is sort of like a static object now? What exactly is "test1"...
3
by: Fei Li | last post by:
Hi, take string class as an example, who can explain the difference? Thanks
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
0
by: Klaus Löffelmann | last post by:
Hi, maybe it's already too late, but what is the deal with overwriting Object.Equals. I have to use "overrides overloads" to really overwrite the correct 'version' of equals, even if a single...
4
by: Rich | last post by:
Hello, Just checking which is more efficient/better/or correct Do While something str1 = dr(i).ToString If Not str1.Equals("xyz") Then .... or
6
by: Edward Diener | last post by:
Now that operator overloading allows to ref classes to be compared for equality using == syntax, how does one compare the actual ref pointers ( ^ ) for equality instead ? As an example: ...
1
by: Rob | last post by:
The code below is almost there (it does change the value for EVERY ORDER).... I simply want to be able to change the value of the Delivered Tag to Yes. BUT ONLY if the Order is equal to 123456 ? ...
2
by: Dragan | last post by:
Hi, We're working in VS 2005, Team edition, if it makes any difference at all (should be up-to-date and all that, but could not guarantee it is 100%). We've implemented a simple generic wrapper...
12
by: Howard Swope | last post by:
This problem has been bugging me for a while. I have created a collection class and implemented it in a C# library. If I inherit from this class in another C# assembly and it works, but if I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.