I have created a buffer class to use with networking, and I use a side-effect to get the buffer pointer, as well as the size. I have created a simple test that displays the same behaviour as the class's getptr() function.
char SomeBuffer[100];
void* getbuf(int& size) {
size = 100;
return SomeBuffer;
}
int testrecv(void* ptr, int size) {
int i = 0;//BREAKPOINT HERE
return 0;
}
int main(int argc, char**argv) {
int size;
testrecv(getbuf(size), size);
}
when I view the variables from within the testrecv() function, size is some random value that was left on the stack. Shouldn't the size in testrecv() be 100, due to the side-effect in getbuf()?