Clang 3.5, 3.6 and 3.7 can't compile a C++11 program with std::bind

Bug #1654795 reported by Jeffrey Walton on 2017-01-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
llvm-toolchain-3.8 (Ubuntu)
Undecided
Unassigned

Bug Description

I'm working on Ubuntu 16 x86_64, fully patched. I'm trying to compile Jack Lloyd's Botan library. Its a C++11 TLS library. It can be found at https://github.com/randombit/botan.

The compile fails with Clang 3.5, 3.6, 3.7 (3.8 is OK). The library fails with the error below.

I found a GCC error report about it, but it was marked as Invalid because its Clang's bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71809.

I was not able to find a LLVM bug report for the issue.

According to Andrew Pinksi from the 71809 bug, here's the discussion about it on CFE-dev: http://lists.llvm.org/pipermail/cfe-dev/2016-March/047761.html.

The short of it is, Ubuntu ships with GCC 6.0. All the affected Clang's need to be compiled against GCC 6.0 and not the GCC 5.3 its currently compiled against.

Please rebuild Clang 3.5, 3.6, 3.7 against the GCC 6.0 gear.

**********

/usr/bin/clang++-3.7 -m64 -pthread -march=native -msse4 -msha -fPIC -fvisibility=hidden -std=c++11 -D_REENTRANT -fstack-protector -O3 -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wunreachable-code -Ibuild/include -c ./src/lib/tls/tls_handshake_hash.cpp -o build/obj/lib/tls_handshake_hash.o
In file included from ./src/lib/tls/tls_channel.cpp:9:
In file included from build/include/botan/tls_channel.h:12:
In file included from build/include/botan/tls_policy.h:11:
In file included from build/include/botan/tls_version.h:11:
In file included from build/include/botan/loadstor.h:12:
In file included from build/include/botan/types.h:16:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/memory:79:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/functional:55:
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/tuple:1400:14: error:
      no matching constructor for initialization of 'tuple<unsigned short &&,
      unsigned char &&, const std::vector<unsigned char, std::allocator<unsigned
      char> > &&>'
    { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/functional:1001:13: note:
      in instantiation of function template specialization
      'std::forward_as_tuple<unsigned short, unsigned char, const
      std::vector<unsigned char, std::allocator<unsigned char> > &>' requested
      here
              std::forward_as_tuple(std::forward<_Args>(__args)...),
                   ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/functional:1740:2: note:
      in instantiation of function template specialization
      'std::_Bind<std::_Mem_fn<void (Botan::TLS::Channel::*)(unsigned short,
      unsigned char, const std::vector<unsigned char, std::allocator<unsigned
      char> > &)> (Botan::TLS::Channel *, std::_Placeholder<1>,
      std::_Placeholder<2>, std::_Placeholder<3>)>::operator()<unsigned short,
      unsigned char, const std::vector<unsigned char, std::allocator<unsigned
      char> > &, void>' requested here
        (*_Base::_M_get_pointer(__functor))(
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/functional:2124:33: note:
      in instantiation of member function 'std::_Function_handler<void (unsigned
      short, unsigned char, const std::vector<unsigned char,
      std::allocator<unsigned char> > &), std::_Bind<std::_Mem_fn<void
      (Botan::TLS::Channel::*)(unsigned short, unsigned char, const
      std::vector<unsigned char, std::allocator<unsigned char> > &)>
      (Botan::TLS::Channel *, std::_Placeholder<1>, std::_Placeholder<2>,
      std::_Placeholder<3>)> >::_M_invoke' requested here
            _M_invoker = &_My_handler::_M_invoke;
                                       ^
./src/lib/tls/tls_channel.cpp:143:19: note: in instantiation of function
      template specialization 'std::function<void (unsigned short, unsigned
      char, const std::vector<unsigned char, std::allocator<unsigned char> >
      &)>::function<std::_Bind<std::_Mem_fn<void
      (Botan::TLS::Channel::*)(unsigned short, unsigned char, const
      std::vector<unsigned char, std::allocator<unsigned char> > &)>
      (Botan::TLS::Channel *, std::_Placeholder<1>, std::_Placeholder<2>,
      std::_Placeholder<3>)>, void, void>' requested here
                  std::bind(&Channel::send_record_under_epoch, this, _1...
                  ^
1 warning and 1 error generated.
Makefile:1219: recipe for target 'build/obj/lib/tls_channel.o' failed
make: *** [build/obj/lib/tls_channel.o] Error 1
make: *** Waiting for unfinished jobs....

Jeffrey Walton (noloader) wrote :

I don't have a minimal, reduced case to reproduce it. But here's how to reproduce it using Botan:

  git clone git://github.com/randombit/botan
  cd botan

  ./configure.py --cc=clang --cc-bin=/usr/bin/clang++-3.{5|6|7}
  make -j 4

When make gets to the file src/lib/tls/tls_handshake_hash.cpp, the compile will fail.

Jeffrey Walton (noloader) wrote :

This may be useful. Someone else reported things were OK on Ubuntu 16.10. I exeprienced the issue under 16.10.1.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial

$ uname -a
Linux ubuntu-16-x64-vm 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26
19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers