Microsoft KB Archive/115325

From BetaArchive Wiki

BUG: Intrinsic Version of strlen() Fails

Q115325

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist ----------------------------------------------------------------------- The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE), included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 ----------------------------------------------------------------------- SYMPTOMS ======== The intrinsic version of the strlen() function fails for arrays larger than 65535 bytes. The compiler options needed to reproduce the problem are /Oi and /AL, as shown with the sample code in the "MORE INFORMATION" section of this article. RESOLUTION ========== The problem can be worked around using one of the following methods: - Compile without /Oi. -or- - Compile with /Od. -or- - Compile with /f- in Visual C++, versions 1.0, 1.50, or 1.50.01. -or- - Use #pragma function(strlen). -or- - Use #pragma optimize("", off) in Visual C/C++ 1.0, 1.50, or 1.50.01. STATUS ====== Microsoft has confirmed this to be a bug in the products listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. This is not a problem in Visual C++ 1.0, 32-bit Edition. MORE INFORMATION ================ The following code can be used to demonstrate this problem: Sample Code ----------- /* Compile options needed: /Oi /AL */ #include #include // #pragma function(strlen) // This line needed to fix the problem char _far sz65535[65536]; void main(void) { size_t length; memset(sz65535, 'A', 65535U); sz65535[65535] = '\0'; length = strlen( sz65535); printf( "Actual Length of string is 65535,\n" "strlen(sz65535) returned %u\n", length); } REFERENCE ========= More information on #pragma can be found in the online Help for Visual C++ or by typing "qh #pragma" at the MS-DOS prompt in C/C++, version 7.0. Additional reference words: 1.00 1.50 7.00 8.00 8.00c KBCategory: kbtool kbbuglist KBSubcategory: CLIss

Keywords : kb16bitonly
Issue type : kbbug
Technology : kbVCsearch kbAudDeveloper kbCVCComp


Last Reviewed: May 5, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.