Microsoft C offsets BUG in 386's

Andrew A. Chernov ache at hq.demos.su
Sun Feb 24 04:59:48 AEST 1991


Hi, folks!
I've found Microsoft C compiler bug in computation offsets in
structures on my XENIX/386 v2.3.3:

  if any field exceed 64K, offsets of next fields are WRONG.

And so, Microsoft programmers can't write their products
without DIRTY bugs.  Use your Microsoft C CAREFULLY! May be,
it can damage all (and you brains also) in one day!

I've check this problem with 'gcc', and get CORRECT result.

NOTE: if you have 286 computer, don't worry about this:
you can't make object bigger than 64K.

This is my test to detect error in your compiler:
------------------------------ CUT HERE -------------------------------
#define SIZE_OVER_64K 100000

struct {
	char    a[SIZE_OVER_64K];
	char    junk[100];
	int     b;
} c;

main()
{
	int i;

	c.b = 1;
	for(i = 0; i < SIZE_OVER_64K; i++)
		if(c.a[i] != 0) {
			printf("THIS 32-bit C COMPILER IS BUGGY !\n");
			exit(1);
		}
	printf("NO ERRORS FOUND.\n");
	exit(0);
}
------------------------------ CUT HERE -------------------------------

-- 
In-Real-Life: Andrew A. Chernov  |  Domain: ache at hq.demos.su,
Zodiac-Sign:  Virgo              |          ache%hq.demos.su at relay.eu.net
Organization: DEMOS Coop.,       |  Phone:  +7 095 2312129
              Moscow, Russia     |  Fax:    +7 095 2335016



More information about the Comp.unix.sysv386 mailing list