]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Avoid constraint recursion with iterator_traits (PR 93983)
authorJonathan Wakely <jwakely@redhat.com>
Thu, 21 May 2020 06:47:17 +0000 (07:47 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 21 May 2020 06:47:17 +0000 (07:47 +0100)
commit566ba72126288272607374a32ac646dcd36fe584
tree174a5d21aa08031bb4fa05c13bcea014fc5366a2
parentefcf41fcfa7351f2e941075d2f1fd73cc282de5b
libstdc++: Avoid constraint recursion with iterator_traits (PR 93983)

Checking whether a filesystem::path constructor argument is an iterator
requires instantiating std::iterator_traits. In C++20 that checks for
satisfaction of std::iterator_traits constraints, which checks if the
type is copyable, which can end up recursing back to the path
constructor. The fix in LWG 3420 is to reorder the cpp17-iterator
concept's constraints to check if the type looks vaguely like an
iterator before checking copyable. That avoids the recursion for types
which definitely aren't iterators, but isn't foolproof.

Backport from mainline
2020-05-21  Jonathan Wakely  <jwakely@redhat.com>

PR libstdc++/93983
* include/bits/iterator_concepts.h (__detail::__cpp17_iterator):
Reorder constraints to avoid recursion when constructors use
iterator_traits (LWG 3420).
* testsuite/24_iterators/customization_points/lwg3420.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/iterator_concepts.h
libstdc++-v3/testsuite/24_iterators/customization_points/lwg3420.cc [new file with mode: 0644]