PRC9108006: C 5.1 _lineto() May Cause R6003 Error

ID Number: Q75249

5.10

MS-DOS

buglist5.10 fixlist6.00

Summary:

PROBLEM ID: C9108006

SYMPTOMS

Attempting to use _lineto() in the Microsoft C Compiler version

5.1 and in the Microsoft QuickC Compiler versions 1.0 and 1.01 to

draw a line to a point that does not lie within the boundaries of

the current graphics screen will cause the following runtime error:

R6003 integer divide by 0

RESOLUTION/STATUS

To avoid the problem, make sure that the coordinates supplied to

the _lineto() function lie within the proper boundary. Refer to

your documentation to find out what the boundary is for each video

mode.

Microsoft has confirmed this to be a problem in C version 5.1 and

QuickC versions 1.0 and 1.01 (buglist1.00 and buglist1.01). This

problem was corrected in C version 6.0 and QuickC versions 2.0

(fixlist2.00).

More Information:

The following program demonstrates this problem. With C 6.0 or QuickC

2.0, the line is drawn until the screen boundary is reached.

Sample Code

-----------

/* Compile options needed: none

*/

#include <graph.h>

#include <conio.h>

void main(void);

void main( )

{

_setvideomode( _MRES4COLOR );

// Drawing a line from (0, 0) to (10, 20) succeeds since both points

// are in bounds. Drawing a line from (10, 20) to (30580, 16660)

// generates the R6003 error in C 5.1, and QuickC 1.0 and 1.01.

_moveto( 0, 0 );

_lineto( 10, 20 );

_lineto( 30580, 16660 );

while( !kbhit( ) );

_setvideomode( _DEFAULTMODE );

}

Additional reference words: 1.00 2.00 6.00