Visual C++ 2003 optimization bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Burlak

    #1

    Visual C++ 2003 optimization bug

    This piece of code prints "Hello, World!" only once if optimizations are
    enabled.
    It is expected to print "Hello, World!" 2^32 times.

    Optimizations: /O2
    Compiler version: 13.10.3077 (VS.Net 2003)

    = = = = = = = = =

    #include <stdio.h>

    void main(void)
    {
    unsigned i = 0;
    do
    {
    printf ("Hello, World!\n");
    ++i;
    }
    while (i != 0);
    }

    = = = = = = = = =
    Best regards,
    Andrew Burlak.


  • David Lowndes

    #2
    Re: Visual C++ 2003 optimization bug

    >This piece of code prints "Hello, World!" only once if optimizations are[color=blue]
    >enabled.
    >It is expected to print "Hello, World!" 2^32 times.[/color]

    Andrew,

    I can repro this incorrect optimization with VS2003, but it appears to
    be resolved with the current Whidbey alpha compiler.

    Merry Christmas
    Dave
    --
    MVP VC++ FAQ: http://www.mvps.org/vcfaq

    Comment

    • Andrew Burlak

      #3
      Re: Visual C++ 2003 optimization bug

      David,
      Thank you for reply.

      I found that this bug was reported in VS.Net 2002:


      It's good news that it is already fixed in Whidbey.

      "David Lowndes" <davidl@mvps.or g> wrote in message
      news:90gmuvsrg6 cp7l6ob5mm0kqj0 0a71obbhs@4ax.c om...[color=blue][color=green]
      > >This piece of code prints "Hello, World!" only once if optimizations are
      > >enabled.
      > >It is expected to print "Hello, World!" 2^32 times.[/color]
      >
      > Andrew,
      >
      > I can repro this incorrect optimization with VS2003, but it appears to
      > be resolved with the current Whidbey alpha compiler.
      >
      > Merry Christmas
      > Dave
      > --
      > MVP VC++ FAQ: http://www.mvps.org/vcfaq[/color]


      Comment

      Working...