FIX: Compiler Errors Initializing const Reference to an Array (116240)
The information in this article applies to:
- Microsoft Visual C++ for Windows, 16-bit edition 1.0
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Editions 4.2
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
This article was previously published under Q116240 SYMPTOMS
Initializing a "const" reference to an array with a "non-const" array
causes incorrect compiler errors to be generated. Two such errors are C2607
and C2561.
CAUSE
The C++ compiler does not properly handle initialization of a "const T&",
where T is an array. For example, you should be able to initialize a
variable of type "const float (&ref)[3][2]" with a variable of type "float
[3][2]", but the compiler does not handle this case. Furthermore,
interactions between const declarations and typedefs of arrays do not work
in all circumstances.
RESOLUTION
To work around the problem, either do not use the const specifier or add
explicit casts to the appropriate const types.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in Microsoft Visual C++ .NET.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbBug kbCompiler kbCPPonly kbfix kbNoUpdate KB116240 |
---|
|