std Namespace Errors

I’ve been updating SAFECode files to work with LLVM 3.7, and I’ve run into a number of errors I can’t explain.

In LLVM_SRC/projects/safecode/runtime/BBRuntime/DebugReport.cpp, there are a host of std::ostream objects that, when given strings with the “<<“ operator, produce errors. Also, the compiler doesn’t seem to recognize std::dec for some reason. Here is a sample of the errors I’m getting:

/Users/peterfinn/Desktop/llvm_trunk_2/projects/safecode/runtime/BBRuntime/DebugReport.cpp:30:6: error: invalid operands to binary expression
(‘std::ostream’ (aka ‘basic_ostream’) and ‘const char *’)
OS << “= Fault PC Source :\t”
~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/memory:5263:1: note: candidate template ignored: could not match
‘shared_ptr’ against ‘char const[43]’
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/string:4191:1: note: candidate template ignored: could not match
‘basic_string<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>’ against ‘char const[43]’
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/Users/peterfinn/Desktop/llvm_trunk_2/projects/safecode/runtime/BBRuntime/DebugReport.cpp:32:20: error: no member named ‘dec’ in namespace ‘std’
<< “:” << std::dec << this->lineNo << “\n”;
~~~~~^
/Users/peterfinn/Desktop/llvm_trunk_2/projects/safecode/runtime/BBRuntime/DebugReport.cpp:38:6: error: invalid operands to binary expression
(‘std::ostream’ (aka ‘basic_ostream’) and ‘const char *’)
OS << “= Pool Handle :\t” << this->PoolHandle << “\n”;
~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/memory:5263:1: note: candidate template ignored: could not match
‘shared_ptr’ against ‘char const[43]’
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/…/include/c++/v1/string:4191:1: note: candidate template ignored: could not match
‘basic_string<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>’ against ‘char const[43]’
operator<<(basic_ostream<_CharT, _Traits>& __os,
^

I’ve been trying to find information online, but I’ve found nothing helpful. I tried creating my own test programs, with my own std::ostream objects, but I couldn’t recreate the errors. Do you have any idea what could be causing this problem?

Thanks,
Peter Finn

Hi Peter,

Seeing as SAFECode is built on top of LLVM it should probably be using
llvm::raw_ostream rather than std::ostream.
This doesn't really answer your question though. I'm afraid I don't
know why you're getting these errors.

You might want to see if the “const” qualifier is causing the problem. The ostream is a basic_ostream while the string you’re passing is a “const char”. Regarding the comment about using LLVM’s stream classes, the code you’re working on is a runtime library linked into applications and is not an LLVM compiler pass. Therefore, using std::ostream should be fine (at least, it shouldn’t be the cause of the problem). Regards, John Criswell