Microsoft KB Archive/87015

= INFO: C2466 Error When Allocating an Array of Length 0 =

Article ID: 87015

Article Last Modified on 10/24/2003

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.51
 * Microsoft Visual C++ 1.52 Professional Edition
 * Microsoft Visual C++ 1.0 Professional Edition

-



This article was previously published under Q87015



SUMMARY
When you use Microsoft C/C++, the constant expression that you use to allocate or declare an array must be an integral type greater than zero. If not, the following error will occur:

C2466: Cannot allocate an array of constant size 0

The following examples are some ways this error can occur: int *p = new X[0];       // error C *aC = new [int_var] C; // error int a[0];                // error int func(char *[0]);     // error NOTE: This does not apply to Visual C++, 32-bit Edition, version 2.0 and later.

If you use the Microsoft extensions (/Ze), an array declaration with a zero subscript is legal for a class, structure, or union member. For more information about valid zero-sized arrays, search the Visual C++ online documentation for the topic &quot;Unsized Arrays.&quot;

Additional query words: 8.00 8.00c 9.00 9.10

Keywords: kberrmsg kbinfo kbcpponly kbcompiler KB87015

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.