BUG: Incorrect Code from Intrinsic memset() RoutineLast reviewed: July 22, 1997Article ID: Q106400 |
1.00 1.50
WINDOWS
kbtool kbbuglist
The information in this article applies to:
SYMPTOMSThe compiler generates incorrect code for the intrinsic form of memset() in certain cases.
CAUSEThe compiler generates incorrect code for memset() if all of the following conditions are met:
RESOLUTIONTo avoid the problem, use a variable instead of a constant for the number of characters (third argument), or eliminate one of the above conditions. See the comments in the sample code below.
STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. This problem does not occur with Visual C++ 32-bit Edition.
MORE INFORMATIONThe following sample code can be used to demonstrate the problem.
Sample Code
/* Compile options needed: </G2 or /G3> and </Oi or /O2> */ #include <stdio.h> #include <string.h> void main( void ){ char ach[11] ; /* int n = 8; */ /* uncomment and use n below */ ach[10] = '\0'; memset( ach, 'A', 10 ); memset( ach, 'B', 8 ); /* to avoid problem use n, not constant 8 */ printf( ach ); if ( ach[7] != 'B' ) printf( "\nsecond memset() failed" ); else printf( "\nsecond memset() succeeded" ); } |
Additional reference words: 1.00 1.50 8.00 8.00c
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |