ID: Q149785
The information in this article applies to:
1.52c
When you use a huge pointer to a structure to reference a member variable whose offset is greater than 32K from the beginning of the structure, a general protection (GP) fault occurs when optimizations are disabled.
The member offset is improperly sign-extended and added to the base address of the structure giving an invalid address.
There are two workarounds:
-or-
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
/* Compile options needed: /Od, /Mq (QuickWin App)
*/
#include <windows.h>
typedef struct {
char table[32768];
int nbtran;
} MyStruct;
MyStruct __huge *lptr;
void main(void)
{
HANDLE hbuff = GlobalAlloc(GMEM_MOVEABLE,60000);
lptr = (MyStruct __huge *) GlobalLock(hbuff);
lptr->nbtran=10; // *** GPF here! ***
}
Keywords : kb16bitonly kbCompiler
Version : 1.5 1.51 1.52 1.52b 1.52c
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: August 11, 1997