BC "Out of Memory" on Calculation with User Type Passed to SUB (78893)



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1

This article was previously published under Q78893

SYMPTOMS

The BC.EXE compiler may give an "Out of Memory" error message when compiling a program that uses elements of a user-defined type in calculations made inside a SUB program to which the typed variable was passed as a parameter. Several workarounds are shown below.

STATUS

Microsoft has confirmed this to be a bug in the Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0; and Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2, versions 7.0 and 7.1 (buglist7.00 and buglist7.1). We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

The following code demonstrates the problem. Compiling the program below in BC.EXE will result in an "Out of Memory" error message:
        TYPE xytype
            a1 AS INTEGER
            a2 AS INTEGER
            a3 AS INTEGER
            a4 AS INTEGER
            a5 AS INTEGER
            a6 AS INTEGER
        END TYPE
        DIM var AS xytype
        DEFINT A-Z
        SUB test (var AS xytype)
            var.a6 = var.a4 * x
            var.a5 = var.a4 + var.a3
            var.a2 = var.a5
            var.a3 = var.a4
        END SUB
				

WORKAROUND

  • Re-arrange the user type. For example, moving a1 to the last position in TYPE xytype corrects the problem.
  • Compile with the /X compile option. Normally, /X indicates the program contains RESUME statements, but it also inhibits some of the compiler's optimizations.
  • Make Var into a variable in COMMON SHARED, thus removing it from the parameter list.

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB78893