Valgrind gives me this:
==26348== Invalid read of size 8
==26348== at 0x4EC3DA8: std::ostream::flush() (in /usr/lib64/libstdc++.so.6.0.19)
==26348== by 0x4E9E477: std::ios_base::Init::~Init() (in /usr/lib64/libstdc++.so.6.0.19)
==26348== by 0x5684E58: __run_exit_handlers (in /lib64/libc-2.17.so)
==26348== by 0x5684EA4: exit (in /lib64/libc-2.17.so)
==26348== by 0x566DAFB: (below main) (in /lib64/libc-2.17.so)
==26348== Address 0xffefffd98 is just below the stack ptr. To suppress, use: --workaround-gcc296-bugs=yes
How do I find where this bug is in my code if it does not point to any line?
I compiled with g++ on a Linux instance in AWS.
EDIT
Okay it seems that somehow I've left the program in an invalid state regarding the streams (thanks) after returning from main. I do make calls to
std::ifstream in(argv[1]);
std::cin.rdbuf(in.rdbuf());
std::ofstream out(argv[2]);
std::cout.rdbuf(out.rdbuf());
Is there anything I need to do here to clean up before returning from main?