Help and Support
 

powered byLive Search

FIX: Visual C++ compiler optimizer may remove loops

Article ID:306083
Last Review:September 26, 2005
Revision:2.1
This article was previously published under Q306083
On This Page

SYMPTOMS

Under certain, rare conditions, the C++ compiler may optimize loops out of a program. When you examine the compiled assembler, you may note that there are functions that do not contain looping instructions, although the source code contains loop constructs.

Back to the top

CAUSE

This problem occurs because of a bug in the global optimizer.

Back to the top

RESOLUTION

Service pack information

To resolve this problem, obtain the latest service pack for Microsoft Visual Studio .NET. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
837234 (http://support.microsoft.com/kb/837234/) List of bugs that are fixed in Visual Studio .NET 2002 Service Pack 1

Back to the top

Hotfix information

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date          Version       Size        File name
   -------------------------------------------------
   11-Apr-2002   13.0.9485.0   1,753,088   C2.dll 
   11-Apr-2002   13.0.9485.0   2,105,344   C1xx.dll 
				


Back to the top

WORKAROUND

To work around the problem, use a larger data type as the iterator value.

Back to the top

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in Visual Studio .NET 2002 Service Pack 1.

Back to the top

MORE INFORMATION

The following program is an example of the behavior. After you build this sample program by using the default compiler settings for release mode, it prints out Loop only one time.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>


int __cdecl _tmain (int argc, _TCHAR* argv[])
{
    unsigned char stream, tmp;

    for (stream = 0; stream < 4; stream++)
    {
        tmp = stream;
        fprintf (stderr, "Loop\r\n", (unsigned char)((tmp+4)<<5));
    }
    return 0;
}
				

Back to the top


APPLIES TO
Microsoft Visual Studio .NET 2002 Professional Edition
Microsoft Visual Studio .NET 2002 Enterprise Architect
Microsoft Visual Studio .NET 2002 Enterprise Developer
Microsoft Visual Studio .NET 2002 Academic Edition
Microsoft Visual C++ .NET 2002 Standard Edition

Back to the top

Keywords: 
kbbug kbfix kbqfe kbvs2002sp1sweep kbvs2002sp1fix kbhotfixserver KB306083

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.