[cfe-dev] FreeBSD clang fails to compile code using boost::archive

Csaba Raduly rcsaba at gmail.com
Fri Apr 4 08:03:28 PDT 2014


Compiling the following code:

#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <algorithm>

std::string Base64::encode(const char *begin, const char *end)
{
    unsigned int padding_chars = (3 - std::distance(begin, end) % 3) % 3;
    std::string base64 {
            boost::archive::iterators::base64_from_binary<        //
this is line 27
                    boost::archive::iterators::transform_width<
                            binary_value::const_iterator, 6, 8>>(
                    begin),
            boost::archive::iterators::base64_from_binary<
                    boost::archive::iterators::transform_width<
                            binary_value::const_iterator, 6, 8>>(
                    end)};
    base64.append(padding_chars, '=');

    return base64;
}

Results in the following error:

$ /usr/bin/c++ -std=gnu++0x -g -Wall -pedantic -Wextra -Wformat=2
-isystem /usr/local/boost/include -isystem /usr/local/include  -c
base64.cc
In file included from base64.cc:11:
/usr/local/include/boost/archive/iterators/transform_width.hpp:113:17:
error: calling a private constructor of class
'std::__1::__wrap_iter<const char *>'
        super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
                ^
/usr/local/include/boost/archive/iterators/base64_from_binary.hpp:94:13:
note: in instantiation of function template specialization
'boost::archive::iterators::transform_width<std::__1::__wrap_iter<const
char
      *>, 6, 8, char>::transform_width<const char *>' requested here
            Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))),
            ^
base64.cc:27:13: note: in instantiation of function template
specialization 'boost::archive::iterators::base64_from_binary<boost::archive::iterators::transform_width<std::__1::__wrap_iter<const
char *>, 6, 8,
      char>, char>::base64_from_binary<const char *>' requested here
            boost::archive::iterators::base64_from_binary<
            ^
/usr/include/c++/v1/iterator:1195:31: note: declared private here
    _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT
: __i(__x) {}
                              ^
1 error generated.

$ c++ -v
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: x86_64-unknown-freebsd10.0
Thread model: posix

Boost is version 1.55 from ports

The same code is compiled successfully with g++48 version 4.8.3
20140220 (prerelease) (FreeBSD Ports Collection)

What could be the cause of the difference?
Csaba
-- 
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds



More information about the cfe-dev mailing list