Could this be a compiler error? My environment is:
- Win7 pro (64-bit)
- VS2012 (update 3)
I compile the tiny console program below. Things work fine for x64 bit release/debug builds. The x32 debug build also works just fine. The x32 release build, however displays 'BUG!'.
If i disable 'Whole Program Optimization' that will fix the issue.
Any ideas?
-
#include <string>
#include <iostream>
int main()
{
std::string const buffer = "hello, world";
std::string::size_type pos = 0;
std::string::size_type previous_pos;
while (pos != std::string::npos)
{
previous_pos = ++pos;
pos = buffer.find('w', pos);
}
if (previous_pos == std::string::npos)
{
std::cout << "BUG!!"<< std::endl;
}
return 0;
}