[cfe-dev] Bug 23307 - clang fails to compile rstudio-0.98.1103/src/cpp/session/modules/SessionHTMLPreview.cpp against libc++

Jack Howarth howarth.mailing.lists at gmail.com
Wed Apr 22 12:54:52 PDT 2015


    Can one of the libc++ experts take a peak at...

https://llvm.org/bugs/show_bug.cgi?id=23307

I am unclear why clang++ with libstdc++ tolerates the following code from
rstudio 0.98.1103...

const char* const MAGIC_GUID = "12861c30b10411e1afa60800200c9a66";
const char* const FIGURE_DIR = "figure-compile-notebook-12861c30b";

bool okToGenerateFile(const FilePath& rmdPath,
                      const std::string& extension,
                      std::string* pErrMsg)
{
   FilePath filePath = rmdPath.parent().complete(
                                    rmdPath.stem() + extension);

   if (filePath.exists())
   {
      boost::shared_ptr<std::istream> pStr;
      Error error = filePath.open_r(&pStr);
      if (error)
      {
         *pErrMsg = "Error opening file: " + error.summary();
         return false;
      }

      std::string magicGuid(MAGIC_GUID);
      std::istreambuf_iterator<char> eod;
      if (eod == std::search(std::istreambuf_iterator<char>(*pStr),
                             eod,
                             magicGuid.begin(),
                             magicGuid.end()))

but clang++ with libc++ errors on the above if statement as...

# clang++ -DBOOST_ASIO_DISABLE_KQUEUE -DBOOST_ENABLE_ASSERT_HANDLER
-DBOOST_SIGNALS_NO_DEPRECATION_WARNING -std=c++11 -stdlib=libc++ -O3
-DNDEBUG -c SessionHTMLPreview.ii
In file included from
/sw/src/fink.build/rstudio-desktop-0.98.1103-5/rstudio-0.98.1103/src/cpp/session/modules/SessionHTMLPreview.cpp:17:
In file included from
/sw/src/fink.build/rstudio-desktop-0.98.1103-5/rstudio-0.98.1103/src/cpp/session/modules/SessionHTMLPreview.hpp:25:
In file included from
/sw/src/fink.build/rstudio-desktop-0.98.1103-5/rstudio-0.98.1103/src/cpp/core/include/core/json/Json.hpp:19:
In file included from
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:1572:12:
error: no matching function for call to
      '__search'
    return std::__1::__search<typename
add_lvalue_reference<_BinaryPredicate>::type>

 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:1586:22:
note: in instantiation of function
      template specialization
'std::__1::search<std::__1::istreambuf_iterator<char,
std::__1::char_traits<char> >, std::__1::__wrap_iter<char *>,
      std::__1::__equal_to<char, char> >' requested here
    return std::__1::search(__first1, __last1, __first2, __last2,
__equal_to<__v1, __v2>());
                     ^
/sw/src/fink.build/rstudio-desktop-0.98.1103-5/rstudio-0.98.1103/src/cpp/session/modules/SessionHTMLPreview.cpp:555:23:
note: in instantiation of function template
      specialization 'std::__1::search<std::__1::istreambuf_iterator<char,
std::__1::char_traits<char> >, std::__1::__wrap_iter<char *> >' requested
here
      if (eod == std::search(std::istreambuf_iterator<char>(*pStr),
                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:1456:1:
note: candidate function [with
      _BinaryPredicate = std::__1::__equal_to<char, char> &,
_RandomAccessIterator1 = std::__1::istreambuf_iterator<char,
std::__1::char_traits<char> >,
      _RandomAccessIterator2 = std::__1::__wrap_iter<char *>] not viable:
no known conversion from 'typename
std::iterator_traits<istreambuf_iterator<char,
      char_traits<char> > >::iterator_category' (aka
'std::__1::input_iterator_tag') to 'std::__1::random_access_iterator_tag'
for 6th argument
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:1419:1:
note: candidate function [with
      _BinaryPredicate = std::__1::__equal_to<char, char> &,
_ForwardIterator1 = std::__1::istreambuf_iterator<char,
std::__1::char_traits<char> >,
      _ForwardIterator2 = std::__1::__wrap_iter<char *>] not viable: no
known conversion from 'typename
std::iterator_traits<istreambuf_iterator<char,
      char_traits<char> > >::iterator_category' (aka
'std::__1::input_iterator_tag') to 'std::__1::forward_iterator_tag' for 6th
argument
__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
^
1 error generated.

Is this a valid error or a glitch in clang++/libc++?
            Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150422/bd68e167/attachment.html>


More information about the cfe-dev mailing list