[comp.lang.c] Microsoft C v5.1 bug

talvola@cory.Berkeley.EDU (Erik Talvola) (04/17/89)

I noticed that someone else posted a Microsoft C bug, so I thought I'd
post my favorite one.  I haven't yet sent this to Microsoft, because all
my registration stuff is at home (while I'm at school...), but maybe
someone from Microsoft will see it (unlikely).  

The program:
---------------------------------------------------------
main(int argc, char **argv)
{
   unsigned char workbm[16][16];
   unsigned char colors[16][16];
   unsigned char pic[8][4][8][2];
   int   i,j,k;

   pic[i][(j>=8)*2][j % 8][0] += workbm[k][j];
   pic[i][(j>=8)*2][j % 8][1] = colors[k][j];
}
---------------------------------------------------------
Yes, it looks hideous, but look at the result of a compilation with
Compact or Large model...

C:\UC> cl -AC editbug.c
Microsoft (R) C Optimizing Compiler Version 5.10
Copyright (c) Microsoft Corp 1984, 1985, 1986, 1987, 1988. All rights reserved.

editbug.c
editbug.c(8) : fatal error C1001: Internal Compiler Error
		(compiler file '@(#)code.c:1.46', line 393)
		Contact Microsoft Technical Support

----------------------------------------------------------

The problem does not exist under Quick C, only Microsoft C, and only appears
when Compact or Large model is used.  Has anyone else ever had Microsoft C
give them an Internal Compiler Error?

--
Erik Talvola               | "It's just what we need... a colossal negative 
talvola@cory.berkeley.edu  | space wedgie of great power coming right at us
..!ucbvax!cory!talvola    | at warp speed." -- Star Drek

pete@octopus.UUCP (Pete Holzmann) (04/21/89)

This is a nasty one I found a few weeks ago. It is fixed in the next version
of MSC, I'm told:

If you #include a file containing function prototype definitions that span
more than one line, then under various wierd circumstances Codeview will
show the #included file rather than your real source code file.

Example:

protos.h contains

void proto1( long a,
	long b);

main.c contains

#include "protos.h"

(any code you like)


If you use a program like READOBJ to look at the generated object file, you'll
find that a second codeview-filename record is inserted into the .OBJ... 
depending on the code in main.c, the linker will either ignore the extra
filename, or will get confused and think that your code is in protos.h.

Pete
-- 
Peter Holzmann, Octopus Enterprises   |(if you're a techie Christian & are
19611 La Mar Ct., Cupertino, CA 95014 |interested in helping w/ the Great
UUCP: {hpda,pyramid}!octopus!pete     |Commission, email dsa-contact@octopus)
DSA office ans mach=408/996-7746;Work (SLP) voice=408/985-7400,FAX=408/985-0859