FIX: Problems Using Parentheses to Denote Array SubscriptsLast reviewed: September 18, 1997Article ID: Q115437 |
1.00 1.50 | 1.00
MS-DOS | WINDOWS NTkbtool kbfixlist kbbuglist The information in this article applies to:
SYMPTOMSCompiling the sample code below with Visual C++ 32-bit Edition causes the compiler to generate the following error message:
fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 602)The compiler should instead generate the following error:
error C2064: term does not evaluate to a functionCompiling the sample code with Visual C++, version 1.5, under Windows NT gives the following error message:
fatal error C1001: internal compiler error (compiler file 'msc1.cpp', line 585)Again, "error C2064: term does not evaluate to a function" should display. When the code below is compiled with Visual C++, versions 1.0 and 1.5 under Windows 3.1, no errors are generated. The compiler effectively ignores the erroneous line. If we compile at warning level 4 (CL /W4), the following warning is generated:
warning C4100: 'push_this' : unreferenced formal parameterThis warning shows that the erroneous line was ignored.
CAUSEIncorrectly compiled code uses parentheses () instead of brackets [] to denote array subscripts.
RESOLUTIONFix the code by changing the parentheses to brackets.
STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. This bug was corrected in C/C++ compiler version 9.0, included in Visual C++ 32-bit Edition, version 2.0.
Sample Code
// Compile options needed: none #include <iostream.h> class stack_class { int stack_data[10]; int stack_ptr; public: void init(void); int push(int push_this); }; void stack_class::init(void) {stack_ptr = -1;}; int stack_class::push(int push_this) { if (stack_ptr >= 99) return(0); //ERROR: (++stack_ptr) - Change to [++stack_ptr] stack_data(++stack_ptr) = push_this; return(1); }; void main() { stack_class stack; stack.push(100); } |
Additional reference words: 1.00 1.50 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |