This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Fix libstdc++/13217


Hi,

tested x86-linux. Something vaguely similar it's probably needed for
write errors too, but we haven't investigated in any detail yet...

Paolo.

///////////
2003-12-10  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/13217
	* include/bits/fstream.tcc (underflow): Deal gracefully with
	read errors: throw ios_base::failure.
diff -prN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
*** libstdc++-v3-orig/include/bits/fstream.tcc	Fri Dec  5 07:54:22 2003
--- libstdc++-v3/include/bits/fstream.tcc	Wed Dec 10 20:11:44 2003
*************** namespace std
*** 258,263 ****
--- 258,265 ----
  		      streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
  		      if (__elen == 0)
  			__got_eof = true;
+ 		      else if (__elen == -1)
+ 			break;
  		      _M_ext_end += __elen;
  		    }
  
*************** namespace std
*** 306,314 ****
  		__throw_ios_failure("basic_filebuf::underflow "
  				    "incomplete character in file");
  	    }
! 	  else
  	    __throw_ios_failure("basic_filebuf::underflow "
  				"invalid byte sequence in file");
  	}
        return __ret;
      }
--- 308,319 ----
  		__throw_ios_failure("basic_filebuf::underflow "
  				    "incomplete character in file");
  	    }
! 	  else if (__r == codecvt_base::error)
  	    __throw_ios_failure("basic_filebuf::underflow "
  				"invalid byte sequence in file");
+ 	  else
+ 	    __throw_ios_failure("basic_filebuf::underflow "
+ 				"error reading the file");	    
  	}
        return __ret;
      }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]