[LLVMbugs] [Bug 11373] New: stderr/cerr inconsistency between clang and clang++ -std=c++11

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 14 12:30:50 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11373

             Bug #: 11373
           Summary: stderr/cerr inconsistency between clang and clang++
                    -std=c++11
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ohsumit at molbio.mgh.harvard.edu
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Hello.  I am not sure what component this goes under, but here's the problem:
under Linux, clang++ prematurely terminates before cerr has a chance to write,
though this does not seem to happen with clang.  Below are two examples, the C
version that works and C++ analog that does not. Note that I have successfully
compiled llvm/clang/clang++/libc++ on my SuSE Linux machine.

clang++ version:
> /tools/llvm/bin/clang++ --version
clang version 3.1 (trunk 144502)
Target: x86_64-unknown-linux-gnu
Thread model: posix

clang/C program that works:
> cat t4.c
#include <stdio.h>
#include <assert.h>
int main(int argc, char* argv[])
{
    fprintf(stderr, "Line 1 testing cerr\n");
    fprintf(stderr, "Line 2 testing cerr\n");
    assert(1 == 0);
    return 0;
}
> /tools/llvm/bin/clang t4.c -o t4
> ./t4
Line 1 testing cerr
Line 2 testing cerr
t4: t4.c:7: int main(int, char **): Assertion `1 == 0' failed.
Aborted

clang++/C++11 program that does not work:
> cat t3.cpp 
#include <iostream>
#include <cassert>
using namespace std;
int main(int argc, char* argv[])
{
    cerr << "Line 1 testing cerr" << endl;
    cerr << "Line 2 testing cerr" << endl;
    assert(true == false);
    return 0;
}
> /tools/llvm/bin/clang++ -std=c++11 -stdlib=libc++ t3.cpp -o t3
> ./t3
Line 1 testing cerrAborted

Note how Line 2 never gets printed.  My understanding what that cerr is not
buffered so it should print both lines before the assertion terminates the
program, right?  

I would be grateful for any information that would resolve this problem.  Many
thanks!

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list