FIX: GP Fault When For Loop Used with Unsigned Char Index (128897)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Professional Edition 2.0
- Microsoft Visual C++, 32-bit Professional Edition 2.1
This article was previously published under Q128897 SYMPTOMS
If you access a structure member when using an unsigned char index in a For
loop, a general protection (GP) fault occurs.
CAUSE
When the compiler is optimizing for speed, only the low byte of the
register where the index is stored is zeroed. Later on, the full extended
register is used in calculating the offset of the structure member. Because
the rest of the register is never zeroed, the offset used is invalid.
RESOLUTION
Use either one of the following workarounds:
- Change the type of the For loop index to any type other than unsigned
char.
-or-
- Do not use speed optimizations.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Microsoft
Visual C++, 32-bit Edition, version 4.0.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbbug kbCompiler kbfix KB128897 |
---|
|