Microsoft KB Archive/115437

= FIX: Problems Using Parentheses to Denote Array Subscripts =

Article ID: 115437

Article Last Modified on 7/5/2005

-

APPLIES TO


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

-



This article was previously published under Q115437



SYMPTOMS
Compiling 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 function

Compiling 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 parameter

This warning shows that the erroneous line was ignored.



CAUSE
Incorrectly compiled code uses parentheses instead of brackets [] to denote array subscripts.



RESOLUTION
Fix the code by changing the parentheses to brackets.



STATUS
Microsoft 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 

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 query words: 1.00 1.50 8.00 8.00c

Keywords: kbbug kbfix kbcpponly kbcompiler KB115437

-

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

© Microsoft Corporation. All rights reserved.