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

            Bug ID: 23141
           Summary: std::bind const-qualifying bound arguments captured by
                    value when compiled as C++14
           Product: libc++
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The following code fails to compile when compiled as C++14:

#include <functional>
#include <type_traits>

struct Fun
{
  template<typename T, typename U>
  void operator()(T && t, U && u) const
  {
    static_assert(std::is_same<U, int &>::value, "");
  }
};

int main()
{
    std::bind(Fun{}, std::placeholders::_1, 42)("hello");
}

The error is:

    static_assert(std::is_same<U, int &>::value, "");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/clang-trunk/bin/../include/c++/v1/__functional_base:415:12: note: in
instantiation of function template specialization
      'Fun::operator()<char const (&)[6], const int &>' requested here
    return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
           ^
/usr/local/clang-trunk/bin/../include/c++/v1/__config:381:15: note: expanded
from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
1 error generated.


When compiled as C++11, the code compiles successfully.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to