Turbo C++ 1.0 Huge pointer addition error?

David K. Drum C512052 at UMCVMB.BITNET
Sun Jan 13 07:24:06 AEST 1991


I am having a problem with huge pointer addition on Turbo C++ 1.0, and suspect
that there may be an error in the compiler itself.  When I attempt to add some
integral value to a huge pointer, the result is the pointer plus the integral
value SQUARED!  For example (in rough code):

typedef struct { . . . } foo;
foo huge *hp1,hp2;
hp1 = (foo huge *) calloc(sizeof(foo),16);  /* 16 foo structures */
/* Do something with foo structure # 1 */
hp2 = hp1 + sizeof(foo);
. . .

In my section of code, calculating the 20-bit addresses of hp1 and hp2 and then
subtracting hp1 from hp2 equals sizeof(foo) squared!  My above code isn't
kosher, I know, so don't tear it up, but it is essentially what I am doing.
I have switched from huge to far, and it works fine, but I need to use huge
pointers.  I have broken down for right now, and I am breaking the pointer
into SEG and OFS, doing the arithmetic myself, and patching them back together
(it works, of course) but I shouldn't have to do that.  Has anyone else found
a similar case, has Borland release a bug fix, and where can I get it?

While I'm thinking about it, I can't use F4 to run to a point in my program
if it isn't already running.  I have to use F7 or F8, then F4 works.  Otherwise
I run out of memory and the computer crashes.

HELP!

David K. Drum  C512052 at UMCVMB.BITNET
                      @UMCVMB.MISSOURI.EDU



More information about the Comp.lang.c mailing list