FIX: Fast Compiler Does Not Check Huge Array Bounds
PSS ID Number: Q102329
Article last modified on 12-21-1993

7.00

MS-DOS


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft C/C++ compiler for MS-DOS, version 7.0
----------------------------------------------------------------------

SYMPTOMS
========

In Microsoft C/C++ version 7.0, the default fast compiler does not
perform any huge array bounds checking. An attempt to compile the code
example below with the C or C++ fast compiler succeeds and no errors
are generated. However, an attempt to compile the same code with
either optimizing compiler (specify the /f- compiler option switch)
fails and the compiler generates the following message:

   C2128 : 'array' : huge array cannot be aligned to segment boundary

STATUS
======

Microsoft has confirmed this to be a problem with the Microsoft C/C++
version 7.0 for MS-DOS. The problem was fixed in Microsoft C/C++ for
MS-DOS version 8.0 which is included with Microsoft Visual C++
version 1.0 Windows.

MORE INFORMATION
================

The following code example demonstrates this problem.

Sample Code - TEST.C or TEST.CPP
--------------------------------

/*
 * Compiler options needed: None
 */

#include <stdio.h>

struct mystruct
{¬
   long a[2048];
   long b[2048];
   long c[2048];
   long d[2049];  // illegal element
} _huge array[20];

void main(void)
{¬
   printf("\nsizeof(array) = %lu\n", (unsigned long)sizeof(array));
}

Additional reference words: 7.00
KBCategory: Prg
KBSubCategory:

=============================================================================

Copyright Microsoft Corporation 1993.
