Microsoft KB Archive/130731

{|
 * width="100%"|

BUG: Division of Long Doubles May Generate Incorrect Code

 * }

Q130731

1.00 1.50 1.51 1.52 WINDOWS kbtool kbbuglist - The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE) included with Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52 - SYMPTOMS ======== Dividing a long double value by a constant may generate incorrect code when the application is built by using the fast compiler. CAUSE ===== The fast compiler may generate code that does not load long double constants correctly. This results in errors in floating-point calculations. The sample code below reproduces the problem. Note that the GetRow function is not called, but the code contributes to the problem. This is because of the long doubles that are being initialized in the function. RESOLUTION ========== Use the optimizing compiler. To specify this from within the Visual Workbench, choose Project from the Options menu, and then select Compiler. Set the Category to Code Generation and change the Code Generator box to Optimizing. The command line option is /f-. The optimizing compiler is used by default when building a release version of an application in the Visual Workbench and when using /O compiler options other than /Od. STATUS ====== 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. MORE INFORMATION ================ Sample Code to Reproduce Problem /* Compile options needed: none */ #include #include void GetRow { long double a = LDBL_MAX; long double b = LDBL_MAX; long double c = LDBL_MAX; long double d = LDBL_MAX; long double e = LDBL_MAX; long double f = LDBL_MAX; long double g = LDBL_MAX; } void main(void) { long double var1; long double var2 = 0.0f; long double var3 = 0.705309f; var1 = (long double) ( ( var2 + var3) / 2.0 ); printf("Should print out 0.325654:\n %Lf\n", var1); } Additional reference words: 1.00 1.50 1.51 1.52 8.00 8.00c KBCategory: kbtool kbbuglist KBSubcategory: CLIss

Keywords : kb16bitonly

Issue type :

Technology :