[llvm-commits] [llvm] r111643 - /llvm/trunk/lib/Support/raw_ostream.cpp
Chris Lattner
clattner at apple.com
Fri Aug 20 17:45:43 PDT 2010
On Aug 20, 2010, at 9:44 AM, Dan Gohman wrote:
> Author: djg
> Date: Fri Aug 20 11:44:56 2010
> New Revision: 111643
>
> URL: http://llvm.org/viewvc/llvm-project?rev=111643&view=rev
> Log:
> Make outs() close its file when its stream is destructed, so that
> pending output errors are detected.
I don't get this. This means that any evaluation (e.g. in a library) of outs() will dramatically change the behavior of the program it is embedded into. This is non-obvious and seems really really dangerous.
-Chris
>
> Modified:
> llvm/trunk/lib/Support/raw_ostream.cpp
>
> Modified: llvm/trunk/lib/Support/raw_ostream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=111643&r1=111642&r2=111643&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Support/raw_ostream.cpp (original)
> +++ llvm/trunk/lib/Support/raw_ostream.cpp Fri Aug 20 11:44:56 2010
> @@ -540,14 +540,16 @@
> }
>
> //===----------------------------------------------------------------------===//
> -// raw_stdout/err_ostream
> +// outs(), errs(), nulls()
> //===----------------------------------------------------------------------===//
>
> /// outs() - This returns a reference to a raw_ostream for standard output.
> /// Use it like: outs() << "foo" << "bar";
> raw_ostream &llvm::outs() {
> // Set buffer settings to model stdout behavior.
> - static raw_fd_ostream S(STDOUT_FILENO, false);
> + // Delete the file descriptor when the program exists, forcing error
> + // detection. If you don't want this behavior, don't use outs().
> + static raw_fd_ostream S(STDOUT_FILENO, true);
> return S;
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list