BUG: QuickBasic Interpreter Allows Duplicate Line Numbers (64431)






This article was previously published under Q64431

SYMPTOMS

The interpreter in Microsoft QuickBasic for Macintosh incorrectly allows duplicate numeric line labels within a program.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 1.00 and 1.00a for Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

At compile time, the compiler in QuickBasic correctly gives the "Duplicate label" error for duplicate line numbers. Note that the interpreter in QuickBasic correctly gives the error "Duplicate label" if the label begins with an alphabetic letter (A through Z). In other words, the problem occurs in the interpreter for duplicate line numbers, but not for duplicate alphanumeric labels.

MORE INFORMATION

Because the QuickBasic interpreter's line number parser fails to check for duplicates, an unlimited number of lines with the same line number are incorrectly allowed. A GOTO or GOSUB to the repeated line number results in control being passed to the first occurrence of the repeated line number. (Compiling the program correctly gives a "Duplicate label" error.)

The following program, when run in interpretive mode, demonstrates the problem:
   Code Example
   ------------

   10 GOSUB 37
   20 END
   37 PRINT "Hello"
   37 PRINT "World"
   100 ' An intermixed line number to better illustrate the problem.
   37 PRINT "How are you doing?"
   50 RETURN
				
Note that QuickBasic does not order lines that have line numbers; for example, line 50 can follow line 100 without any numeric order enforced. No line-numbering order is enforced because line numbers are merely another form of line label in the QuickBasic language.
   Output from Example
   -------------------

   Hello
   World
   How are you doing?
				

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: kbbug KB64431