[comp.os.msdos.programmer] Two problems/bugs in Turbo C++ 1.01

gershon@cs.utah.edu (Gershon Elber) (03/15/91)

The following small C file causes Turbo C++ 1.01 to die with a FATAL
error:

---------------------------------------------------------------------------
#include <math.h>
extern int cond1, cond2;

void bug(double *x)
{
	*x = cond1 ? (cond2 ? pow(10.0, 2) : 2.0) : 3.0;
}
---------------------------------------------------------------------------

TC++ 1.01 gives the following FATAL error:

Fatal F:\BUG.C 7: Register allocation failure in function bug.

Interestingly enough replacing the pow() function with a constant "fix" this
problem.

I have not checked it on Borland C++ 2.0 since I do not have it...

*****************************************************************************

One would expects text displayed via outtext/xy to be clipped to the viewport
much the same way lines are. In fact most of Borland's driver do exactly that
(EGAVGA, CGA, HERCULES). However VGA256.BGI (Also from Borland although not
official) does not, and so are some SVGA drivers around.

Try the following sequence on your favorite BGI driver (you may be surprised):
---------------------------------------------------------------------------
    setcolor(1);
    outtextxy(0, 0, "Text at 0,0 (view port = all screen)");

    x1 = 50;
    y1 = 50;
    x2 = getmaxx() - 50;
    y2 = getmaxy() - 50;

    moveto(x1, y1);
    lineto(x1, y2);
    lineto(x2, y2);
    lineto(x2, y1);
    lineto(x1, y1);
    setviewport(x1, y1, x2, y2, TRUE);

    outtextxy(0, 0, "Text at 0,0 (view port = 50 pixel inner)");

    outtextxy(-25, -25, "Text at -25,-25 (view port = 50 pixel inner)");
    outtextxy( 25, -25, "Text at  25,-25 (view port = 50 pixel inner)");
    outtextxy(-25,  25, "Text at -25, 25 (view port = 50 pixel inner)");
---------------------------------------------------------------------------
The last 3 calles to outtextxy should be partially/fully clipped but are
unfortunetelly fully displayed on some drivers. Note all drivers correcly
place the text relative to the viewport but only some clip them as well.

Gershon
Elber Gershon                            gershon@cs.utah.edu
918 University village
Salt Lake City 84108-1180                Tel: (801) 582-1807 (Home)
Utah                                     Tel: (801) 581-7888 (Work)