[comp.sys.ibm.pc.programmer] This can't be a TurboC bug can it?

tom@stiatl.UUCP (Tom Wiencko) (08/01/90)

CRN@BYUVM.BITNET writes:

>I am having a VERY weird problem in TurboC.  My code looks
>something like this:

>typedef struct{
>   . . .
>   char   *str;
>int    type;
>}FIELD;

>int proc(FIELD *fld)
>{
>   . . .
>   if(!valid_str(fld->str))
>      return ERROR;
>   . . .
>}

Turn off register optimization.  There must be some code around the 
function call which also uses the pointer - and with register optimization
turned on the compiler sometimes "forgets" which registers he has used
and which still have valid pointers in them.

Took me two days of intense debugging to find this, and it was confirmed
by Borland tech support.  They also said that there is at this time no
fix for the problem.  

I am not sure if Turbo C++ has the same bug - I have not tested it yet
(but I have left the optimization off...).

Tom

-- 
Tom Wiencko                                            (w) (404) 977-4515
gatech!stiatl!tom                                  Wiencko & Associates, Inc.