Dear all,<br><br>Consider there is a program that writes to stdout using two different raw_fd_ostream-s:<br><br><span style="font-family:courier new,monospace">#include "llvm/LLVMContext.h"<br>#include "llvm/Module.h"<br>
#include "llvm/Support/raw_ostream.h"<br><br>using namespace llvm;<br><br>int main()<br>{<br>        raw_fd_ostream S(STDOUT_FILENO, false);<br><br>        outs() << "Hello";<br>        S << ", world!";<br>
<br>        return 0;<br>}</span><br><br>With this layout everything is fine, it prints ", world!Hello"<br><br>Now, make S definition global:<br><br><span style="font-family:courier new,monospace">#include "llvm/LLVMContext.h"<br>
#include "llvm/Module.h"<br>#include "llvm/Support/raw_ostream.h"<br><br>using namespace llvm;<br><br>raw_fd_ostream S(STDOUT_FILENO, false);<br><br>int main()<br>{<br>        outs() << "Hello";<br>
        S << ", world!";<br><br>        return 0;<br>}</span><br><br>And... surprisingly:<br><br><span style="font-family:courier new,monospace">$ ./outs <br>Hello, world!$ ./outs &>result<br>$ cat result <br>
HelloLLVM ERROR: IO failure on output stream.</span><br><br>So, no error with screen output and error when redirected to file. Why so?<br><br>Thanks,<br>- D.<br><br>