diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-02 13:43:32 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-02 13:43:32 +0200 |
commit | 3634d3ca7c659867beaf7c2e4eaceddd062ea4dd (patch) | |
tree | fdf945042fc737c5b6e7b63f99478c4608f95dd9 | |
parent | 1ae0cd48961c6340fe16dc62d888096773d57cc0 (diff) |
Check for eof before streaming rdbuf
-rw-r--r-- | build2/cxx/compile.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index 5e7a1b2..c2a6be8 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -1208,10 +1208,16 @@ namespace build2 } } - // In case of VC++, we are parsing stderr and if things go south, - // we need to copy the diagnostics for the user to see. + // In case of VC++, we are parsing stderr and if things go + // south, we need to copy the diagnostics for the user to see. // - if (!is.eof () && cid == "msvc" && bad_error) + // Note that the eos check is important: if the stream is at + // eos, this and all subsequent writes to cerr will fail (and + // you won't see a thing). + // + if (is.peek () != ifdstream::traits_type::eof () && + cid == "msvc" && + bad_error) cerr << is.rdbuf (); is.close (); |