BC.EXE "Internal Error" using SGN Function on Parameter in SUB (77837)



The information in this article applies to:

  • 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 Q77837

SYMPTOMS

The following compiler error
BC : internal error near xxxx
can occur when the SGN(x) function is used in a SUB with an equation that uses a passed integer variable. This problem does not occur in the QBX.EXE environment, or in versions earlier than 7.0 of the BC.EXE compiler that is included with Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2.

STATUS

Microsoft has confirmed this to be a bug with Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2, versions 7.0 and 7.1. This problem was corrected in Microsoft Visual Basic version 1.0 for MS-DOS.

MORE INFORMATION

Code to Reproduce Problem

   DECLARE SUB Test (I%)

   SUB Test (I%)
      FOR I% = 1 to 2
           C = SGN(B) * I%
      NEXT I%
   END SUB
				
To compile the program, type the following at the DOS prompt:

BC TEST;

The error message "BC : internal error near xxxx" results. To avoid this error, use one of the following workarounds:

  • Compile with /X (this inhibits compiler optimization, and affects how the code is generated).
  • Reverse SGN(B) and I% in the equation C = SGN(B) * I%
  • Change the passed parameter to any type other than integer.
  • Avoid using the passed integer(s) in the equation.
  • Instead of using I% as the passed variable, use I along with DEFINT A-Z to cause the default type to be INTEGER.
Note the following:

  • Compiling with BC /D does not correct the problem.
  • The passed variable must be explicitly declared as an integer to cause the problem; DEFINT A-Z will not cause a problem.
  • The error occurs using any math operator in the equation (for example, C = SGN(B) + I% will yield the same error message.)

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:KB77837