public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104546] New: std::reference_wrapper doesn't compile with clang in some circumstances
@ 2022-02-15 10:05 redi at gcc dot gnu.org
  2022-11-29 18:52 ` [Bug libstdc++/104546] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-02-15 10:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104546

            Bug ID: 104546
           Summary: std::reference_wrapper doesn't compile with clang in
                    some circumstances
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <functional>
#include <vector>
#include <algorithm>

int main() {
    std::function<bool(const int&, const int&)> comp 
        = [](const int& a, const int& b) { return a < b; };

    std::vector<int> vec;
    std::sort(vec.begin(), vec.end(), std::ref(comp)); // Doesn't compile
}

This fails with clang due to https://github.com/llvm/llvm-project/issues/53049 


In file included from repro.cc:1:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/functional:58:
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:319:40:
error: exception specification of
'function<__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>, void>' uses itself
                = decltype(reference_wrapper::_S_fun(std::declval<_Up>()))>
                                                     ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:319:40:
note: in instantiation of exception specification for
'function<__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>, void>' requested here
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/refwrap.h:321:2:
note: in instantiation of default argument for
'reference_wrapper<__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>, void>' required here
        reference_wrapper(_Up&& __uref)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:1017:57:
note: while substituting deduced template arguments into function template
'reference_wrapper' [with _Up =
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>, $1 = (no value), $2 = (no value)]
      = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>;
                                                        ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:1023:14:
note: in instantiation of template type alias '__is_nothrow_constructible_impl'
requested here
    : public __is_nothrow_constructible_impl<_Tp, _Args...>::type
             ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/type_traits:153:14:
note: in instantiation of template class
'std::is_nothrow_constructible<__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>,
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>>' requested here
    : public conditional<_B1::value, _B2, _B1>::type
             ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/std_function.h:298:11:
note: (skipping 7 contexts in backtrace; use -ftemplate-backtrace-limit=0 to
see all)
          return __and_<typename _Base::_Local_storage,
                 ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:1917:12:
note: in instantiation of function template specialization
'std::__heap_select<__gnu_cxx::__normal_iterator<int *, std::vector<int>>,
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>>' requested here
      std::__heap_select(__first, __middle, __last, __comp);
           ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:1933:13:
note: in instantiation of function template specialization
'std::__partial_sort<__gnu_cxx::__normal_iterator<int *, std::vector<int>>,
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>>' requested here
              std::__partial_sort(__first, __last, __last, __comp);
                   ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:1954:9:
note: in instantiation of function template specialization
'std::__introsort_loop<__gnu_cxx::__normal_iterator<int *, std::vector<int>>,
long,
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>>' requested here
          std::__introsort_loop(__first, __last,
               ^
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:4875:12:
note: in instantiation of function template specialization
'std::__sort<__gnu_cxx::__normal_iterator<int *, std::vector<int>>,
__gnu_cxx::__ops::_Iter_comp_iter<std::reference_wrapper<std::function<bool
(const int &, const int &)>>>>' requested here
      std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
           ^
repro.cc:10:10: note: in instantiation of function template specialization
'std::sort<__gnu_cxx::__normal_iterator<int *, std::vector<int>>,
std::reference_wrapper<std::function<bool (const int &, const int &)>>>'
requested here
    std::sort(vec.begin(), vec.end(), std::ref(comp)); // Doesn't compile
         ^
1 error generated.


If possible we should try to workaround this.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug libstdc++/104546] std::reference_wrapper doesn't compile with clang in some circumstances
  2022-02-15 10:05 [Bug libstdc++/104546] New: std::reference_wrapper doesn't compile with clang in some circumstances redi at gcc dot gnu.org
@ 2022-11-29 18:52 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-29 18:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104546

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-11-29
             Status|UNCONFIRMED                 |NEW

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-29 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 10:05 [Bug libstdc++/104546] New: std::reference_wrapper doesn't compile with clang in some circumstances redi at gcc dot gnu.org
2022-11-29 18:52 ` [Bug libstdc++/104546] " redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).