From 3634d3ca7c659867beaf7c2e4eaceddd062ea4dd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 2 Aug 2016 13:43:32 +0200 Subject: Check for eof before streaming rdbuf --- build2/cxx/compile.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'build2/cxx/compile.cxx') 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 (); -- cgit v1.1