Data getting clobbered in function call

Hey, I'm getting a really weird bug where some of my class data is getting overwritten before the body of the function executes. I can't seem to reduce it to a small test case, but the code looks something like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Foo
{
public:
    const int& X;
    const int& Y;
    Foo()
      : X(x),
      Y(y)
    {
        y = 0;
        x = 0;
    }
private:
    int x;
    int y;
};


void AddFoo(Foo* theFoo)
{
    //function body here
}


In the code its only the references that get garbled, the original variables retain their values. The actual code is in the function AddFBO(FrameBufferObject* fbo) which you can look at here: http://github.com/slicedpan/GLUtils/blob/master/FBOManager.h . The definition for FrameBufferObject is here: http://github.com/slicedpan/GLUtils/blob/master/FrameBufferObject.h

The variables that are getting destroyed are the references Width and Height, again the variables they actually point to stay the same. Using VS2010, if I put a breakpoint at the opening brace of the function, the data is fine, but stepping through destroys the data, but this is before any of the function body executes. Looking at the disassembly, the instruction that causes this is a 'rep stos' instruction, and the value it is storing is 0xcccccccc, which I believe is a default pointer value used by the compiler, but I'm not familiar enough with assembly to be any more specific. Any help would be much appreciated.
Thanks
Topic archived. No new replies allowed.