Article: Q61918
Product(s): See article
Version(s): 6.00 | 6.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | buglist6.00 | mspl13_c
Last Modified: 13-JUN-1990
The code sample shown below generates the following internal compiler
error when compiled with /Oe in either small or medium memory model:
foo2.c(16) : fatal error C1001: Internal Compiler Error
(compiler file '@(#)regMD.c:1.100', line 1017)
Contact Microsoft Product Support Services
Sample Code
-----------
#include <dos.h>
#include <malloc.h>
typedef struct {
unsigned offset ;
unsigned usize ;
} struct1 ;
void foo (unsigned handle, struct1 *pdata)
{
unsigned char far *buffer ;
unsigned numbytes ;
FP_OFF (buffer) = pdata->offset = (unsigned) malloc (pdata->usize) ;
_dos_read (handle, buffer, (unsigned) pdata->usize, &numbytes) ;
}
There are three workarounds possible for this specific problem:
1. Do not compile with the /Oe switch.
2. Use the optimize pragma to disable the /Oe optimization for this
particular routine. Above the routine foo, add the following line:
#pragma optimize ("e", off)
After the closing curly bracket of foo, you can turn the optimization
back on with the following:
#pragma optimize ("e", on)
3. Use a temporary variable for the return value of malloc, as
follows:
unsigned offset ;
offset = (unsigned) malloc (pdata->usize) ;
FP_OFF (buffer) = pdata->offset = offset ;
Microsoft has confirmed this to be a problem with C version 6.00. We
are researching this problem and will post new information here as it
becomes available.