Path: utzoo!attcan!uunet!cs.utexas.edu!swrinde!ucsd!sdd.hp.com!samsung!xylogics!world!goodearl From: goodearl@world.std.com (Robert D Goodearl) Newsgroups: comp.windows.ms Subject: Re: WINDOWS 3 w/ MSC V6.0 Summary: C 6.0 bug Message-ID: <1990Jun13.200907.3269@world.std.com> Date: 13 Jun 90 20:09:07 GMT References: Sender: Bob Goodearl Organization: The World Lines: 37 In article root@scona (Corey Wirun) writes: > > I've got a program written in MSC V5.1 tht works fine with >Windows 3. When the same program is compiled with MSC V6.0, I get a >system integrity error in Windows. > A couple of other guys in my development group and I found a bug in C 6.0 that may be responsible for the fault you are seeing. The bug shows up when using getc in its macro form, and when getting the last char from the internal buffer that getc uses. The real problem is related to using the & operator on the data from a char pointer and assigning the result to a register integer. //The code that demonstrated the bug is as follows: register int x; char *cp; x = 0x7f & *cp; //or x = 0x7f & getc(); //When you fetch the last char in the buffer that getc uses, the above code //will produce a memory fault because the generated code does a word fetch //rather than a byte fetch and the last char of the buffer is on the edge of //valid memory. Our bug showed up when doing the 512th getc(). One solution for this bug is to do the following: #define register and not use explicit register variables. Bob Goodearl -- goodearl@world.std.com