Quote:Original post by DrEvil
post GetEvents
Ahhhh crap..
Damn!
*Hangs head in shame*
GetEvents() was supposed to return a const reference to the array object. Instead, missing the & operator on the return value, it was returning a copy of it.
I can't believe this code has been running for months like this.
Thank you DrEvil, I am royally indebted to you. If there's anything I can do to return the favor, let me know. You probably just saved me a week.
Is there any way to avoid these types of typos? I could have more right now. Shouldn't the compiler warn about storing a copy of something being returned from a function into a reference variable?
Thanks again for your simple and insanely useful reply.
edit:
There's still one thing I don't understand, though. If there was a new copy being generated every time I called GetEvents(), then how did the first five validation checks succeed? Did it just happen to copy the array object over onto the same memory the first five times?
edit 2:
Uhh, I should also give thanks to popsoftheyear. If I would have looked more closely after his suggestion, I would have found it.
[Edited by - Kest on August 13, 2007 5:59:49 PM]