Aram Hambardzumyan
Sep 16, 2004, 07:01
This seems like another bug in compiler but I would like to hear your opinions as well. In the code below the class defines two members: an array and a reference to that array (with scalar type of first member, everything works well). when the function S::f(const S& s) is invoked, the value for s.ri changes. I'd like to mention that function f isn't necessarily to be the member of the same S as it's argument, I did this way just in order not to introduce another struct/class.
As comments describe, value of s.ri coincides with s.i just before entering function body, and differs right after it:
struct S
{
int i[10];
int*const& ri;
S(): ri(i) { }
void f(const S& s);
};
void S::f(const S& s)
{ // still ok
} // here the change appears
int
main(int argc, char* argv[])
{
S s;
s.f(s);
return 0;
}
P. S. This happened both with first .net compiler as well as with .net 2003, but not with msvc6
As comments describe, value of s.ri coincides with s.i just before entering function body, and differs right after it:
struct S
{
int i[10];
int*const& ri;
S(): ri(i) { }
void f(const S& s);
};
void S::f(const S& s)
{ // still ok
} // here the change appears
int
main(int argc, char* argv[])
{
S s;
s.f(s);
return 0;
}
P. S. This happened both with first .net compiler as well as with .net 2003, but not with msvc6