Microsoft KB Archive/67314

= BC.EXE &quot;Out of Memory&quot; with Numeric Array Elements and SWAP =

Article ID: 67314

Article Last Modified on 11/21/2006



This article was previously published under Q67314



SYMPTOMS
Compiling the following code segment with the BC.EXE compiler gives a &quot;BC : Out of memory&quot; error. The problem will occur for any simple mathematical operation (addition, subtraction, multiplication, or division) performed on the two static-array elements appearing in the assignment statement below. The problem does not occur in the QBX.EXE environment. DIM d#(1), e#(1), b!(1), c&(1) n = 1 a% = b!(n) + c&(n) SWAP d#(n), e#(n)



WORKAROUND
You can work around the problem in any one of the following ways:

 Compile the program with the BC /D option to produce debug code.  Use the CINT or CLNG function to convert the first array element in the mathematical expression to an integer type. The example above will compile without error if the assignment statement is changed as follows: a%= CINT(b!(n)) + c&(n)   Save one of the variables being swapped to a temporary variable and use the temporary variable as an argument to the SWAP statement. The example above will compile without error if the SWAP statement is changed as follows: f# = d#(n) SWAP f#,e#(n)  Use dynamic arrays (instead of static arrays) by adding REM $DYNAMIC to the top of the program.



STATUS
Microsoft has confirmed this to be a bug in BC.EXE in Microsoft Basic Profession Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The problem occurs when all of the following conditions occur simultaneously (as shown in the first code example):


 * 1) An integer variable (INTEGER or LONG type) is assigned to the addition, multiplication, division, or subtraction of two numeric static-array elements.
 * 2) The first array element in the mathematical expression is of type SINGLE.
 * 3) The second array element in the mathematical expression is of type LONG.
 * 4) A SWAP of two array elements of any numeric type occurs after the assignment statement.
 * 5) The code is compiled using BC.EXE

Additional query words: BasicCom buglist7.00 buglist7.10

Keywords: KB67314

-

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

© Microsoft Corporation. All rights reserved.