Microsoft KB Archive/263609

= BUG: Bad Code for Unsigned and Signed Comparisons with /Og =

Article ID: 263609

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q263609



SYMPTOMS
The compiler may generate incorrect code for a signed comparison following an unsigned same comparison when the /Og optimization is enabled.

Please refer to the sample code in the &quot;More Information&quot; section for details.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
The following sample code demonstrates the bug: // Test.cpp // Compiler option needed: /Og int a=-1; void main { if ((unsigned int)a > 5U) { if (a > 5) { printf(&quot;%d > 5\n&quot;, a); } else { printf(&quot;%d < 0\n&quot;, a); }   } else { printf(&quot;0 <= %d <= 5\n&quot;, a); } }
 * 1) include 

Program Output:

-1 > 5

Keywords: kbbug kbcodegen kbcompiler KB263609

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.