https://llvm.org/bugs/show_bug.cgi?id=27244
Bug ID: 27244 Summary: clang C++ error passing an std::function to std::stable_sort with --std=c++14 Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++14 Assignee: unassignedclangb...@nondot.org Reporter: malcolm.pars...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Clang reports an error when compiling this code as C++14. Clang reports no errors when compiling it as C++11. GCC reports no errors for C++11 or C++14. $ cat functiontest.cpp #include <algorithm> #include <functional> #include <vector> class Foo { }; void sortMyVector(std::vector<Foo>& foos, std::function<bool(const Foo&, const Foo&)> fn) { std::stable_sort(begin(foos), end(foos), fn); } $ g++ --version g++ (GCC) 5.3.0 ... $ clang++ --version clang version 3.8.0 (tags/RELEASE_380/final) ... $ g++ -c --std=c++11 functiontest.cpp $ g++ -c --std=c++14 functiontest.cpp $ clang++ -c --std=c++11 functiontest.cpp $ clang++ -c --std=c++14 functiontest.cpp In file included from functiontest.cpp:1: In file included from gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/algorithm:61: In file included from gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/stl_algobase.h:71: gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/predefined_ops.h:123:31: error: indirection requires pointer operand ('Foo' invalid) { return bool(_M_comp(*__it1, *__it2)); } ^~~~~~ gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:1981:27: note: in instantiation of function template specialization '__gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const Foo &, const Foo &)> >::operator()<Foo, Foo>' requested here using _Invoke = decltype(__callable_functor(std::declval<_Functor&>()) ^ gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:1990:2: note: in instantiation of template type alias '_Invoke' requested here using _Callable ^ gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:2057:30: note: in instantiation of template type alias '_Callable' requested here typename = _Requires<_Callable<_Functor>, void>> gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/functional:2058:2: note: in instantiation of default argument for 'function<__gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const Foo &, const Foo &)> > >' required here function(_Functor); ^~~~~~~~ gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/predefined_ops.h:130:14: note: while substituting deduced template arguments into function template 'function' [with _Functor = __gnu_cxx::__ops::_Iter_comp_iter<std::function<bool (const Foo &, const Foo &)> >, $1 = (no value)] { return _Iter_comp_iter<_Compare>(__comp); } ^ gcc-5.3.0/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/bits/stl_algo.h:4933:27: note: in instantiation of function template specialization '__gnu_cxx::__ops::__iter_comp_iter<std::function<bool (const Foo &, const Foo &)> >' requested here __gnu_cxx::__ops::__iter_comp_iter(__comp)); ^ functiontest.cpp:12:10: note: in instantiation of function template specialization 'std::stable_sort<__gnu_cxx::__normal_iterator<Foo *, std::vector<Foo, std::allocator<Foo> > >, std::function<bool (const Foo &, const Foo &)> >' requested here std::stable_sort(begin(foos), end(foos), fn); ^ 1 error generated -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs