S
Serge Skorokhodov (216716244)
Hi,
I don't know whether this is a known buf. The following snippet:
== start ==
#include "stdafx.h"
#include <iostream>
#include <tchar.h>
int _tmain(int argc, _TCHAR* argv[])
{
char c[4];
c[0]='a';
c[1]='b';
c[2]='c';
c[3]='d';
std::cout << "before: " << c[0] << c[1] << c[2] << c[3] << " ";
for (int n=2 ; n>0; --n)
{
for (int i=0; i<3; i++)
{
c = c[i+1];
}
c[3] = 'x';
}
std::cout << "after: " << c[0] << c[1] << c[2] << c[3] <<
std::endl;
return 0;
}
== end ==
produces output "before: abcd after: cdxx" without /O2
and "before: abcd: after: cxxx" with /O2
TIA
I don't know whether this is a known buf. The following snippet:
== start ==
#include "stdafx.h"
#include <iostream>
#include <tchar.h>
int _tmain(int argc, _TCHAR* argv[])
{
char c[4];
c[0]='a';
c[1]='b';
c[2]='c';
c[3]='d';
std::cout << "before: " << c[0] << c[1] << c[2] << c[3] << " ";
for (int n=2 ; n>0; --n)
{
for (int i=0; i<3; i++)
{
c = c[i+1];
}
c[3] = 'x';
}
std::cout << "after: " << c[0] << c[1] << c[2] << c[3] <<
std::endl;
return 0;
}
== end ==
produces output "before: abcd after: cdxx" without /O2
and "before: abcd: after: cxxx" with /O2
TIA