BC.EXE "Internal Error" Using Passed Integers in Expression (39245)






This article was previously published under Q39245

SYMPTOMS

An "internal error" is produced when compiling the sample code fragment (below) with BC.EXE. The problem relates to a compiler code-optimization problem in a particular case of passing integer variables as parameters to a subprogram and using them in certain expressions.

STATUS

Microsoft has confirmed this to be a bug in BC.EXE in Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, and in the Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2 (buglist6.00, buglist6.00b). This problem was corrected in Microsoft Basic Professional Development System (PDS) Version 7.00 (fixlist7.00)

To work around this problem, assign a temporary value to one of the integer parameters before doing arithmetic (see below).

MORE INFORMATION

The following code example causes an "internal error":
DECLARE SUB XSCROLL (BarLen%, LCol%, BRow%, Rcol%)
SUB XSCROLL (BarLen%, LCol%, BRow%, Rcol%)
   LCol% = LCol% + 3
   NumCol# = ((Rcol% - LCol%) + 1) \ BarLen%
END SUB
				
The following code example works around the problem:
DECLARE SUB XSCROLL (BarLen%, LCol%, BRow%, Rcol%)
SUB XSCROLL (BarLen%, LCol%, BRow%, Rcol%)
   temp1% = LCol%
   temp1% = temp1% + 3
   LCol% = temp1%
   NumCol# = ((Rcol% - LCol%) + 1) \ BarLen%
END SUB
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB39245