KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q65358: C 6.00 Incorrectly Evaluates Pointer Arrays to Constant Data

Article: Q65358
Product(s): See article
Version(s): 6.00   | 6.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | s_quickc buglist6.00 | mspl13_c
Last Modified: 17-DEC-1990

When an array of pointers to constant data is declared, the C version
6.00 and QuickC versions 2.50 and 2.51 compilers incorrectly consider
both pointers and data to be constant.

The following sample code demonstrates the problem:

void main(void)
{
 const int *p[1];
 const int Z = 0;

 p[0] = &Z;
}

When the sample code is compiled, the following two errors are
produced:

   warning C4132: 'p': const object should be initialized

   error C2166: lvalue specifies const object

Only the data should be constant in this case. The compiler considers
the pointers to be constant, which is in error, and does not allow
their value to be changed.

Microsoft has confirmed this to be a problem with the Microsoft C
Compiler version 6.00. We are researching this problem and will post
new information here as it becomes available.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.