http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50951
Bug #: 50951 Summary: state of subtract_with_carry_engine not saved correctly to output stream Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: dariom...@hotmail.com the value of __x._M_p is not written to output stream __os by operator<<(std::basic_ostream<_CharT, _Traits>& __os,const subtract_with_carry_engine<_UIntType,__w,__s,__r>& __x) in 4.6.1/include/c++/bits/random.tcc. Consequently, the state of the random engine is not fully restored by the corresponding operator>>. One way to fix the problem is to write __x._M_p to output stream __os. Alternatively, the contents of the ring buffer could be saved and restored always beginning at index __x._M_p, whatever its value, and then wrapping around the ring buffer as necessary.