FIX: Error C2593: 'operator +' Is Ambiguous (128344)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 2.0
- Microsoft Visual C++, 32-bit Professional Edition 4.1
- Microsoft Visual C++, 32-bit Professional Edition 4.0
- Microsoft Visual C++, 32-bit Professional Edition 2.1
- Microsoft Visual C++ 1.52
- Microsoft Visual C++, 32-bit Learning Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Learning Edition 4.0
- Microsoft Visual C++ 1.51
- Microsoft Visual C++ 1.5
- Microsoft Visual C++ 1.0
- Microsoft C/C++ for MS-DOS 7.0
This article was previously published under Q128344 SYMPTOMS
When enumerated types are used in some (+-*/|&^%) operator overloads, the
Microsoft compilers listed above may generate the following message:
Error C2593: 'operator +' is ambiguous
In Visual C++, 32-bit edition, version 2.1, the following warnings are also
displayed:
Warning C4387: 'enum Test __cdecl operator+(enum Test, enum Test)':
was considered
Warning C4388: and built-in global operator was considered
The "Sample Code" section in this article demonstrates this problem.
CAUSE
Without determining that there is an exact operator overload match, the
compiler is considering the enumerator types promoted to int type. This
causes the C2593 ambiguous error.
RESOLUTION
Use one of the following three workarounds:
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Visual C++
version 5.0.
REFERENCES
More information about operator overloading can be found in "The Annotated
C++ Reference Manual (Jan '94)" section 13.4.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbbug kbcode kbCompiler kbCPPonly kbfix kbVC500fix KB128344 |
---|
|