http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53626
Bug #: 53626 Summary: move assignment for ifstream Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: mikhail_seme...@hotmail.com Created attachment 27599 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27599 The program The move assignment operator should be provided for ifstream. The following program fails to compile. It should print out the contents of a text file, whose first line starts with "My File". #include <iostream> #include <string> #include <fstream> std::ifstream OpenMyFile(const std::string& filename) { std::ifstream file(filename); if (!file.good()) { file.close(); return file; } std::string s; std::getline(file, s); if (s.substr(0,7) != "My File") { file.close(); file.setstate(std::ios_base::failbit); return file; } return file; } int main(int count, char *args[]) { if (count < 2) { std::cout << "Incorrect number of parameters" << std::endl; return -1; } std::ifstream myFile = OpenMyFile(args[1]); if (myFile.good()) { while (!myFile.eof()) { std::string s; std::getline(myFile,s); std::cout << s << std::endl; } } else { std::cout << "*** FILE ERROR ***" << std::endl; } return 0; }