libstdc++: Avoid constraint recursion with iterator_traits (PR 93983)
authorJonathan Wakely <jwakely@redhat.com>
Thu, 21 May 2020 06:32:15 +0000 (07:32 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 21 May 2020 06:32:15 +0000 (07:32 +0100)
commitf094665d465cdf8903797cc58bea13007e588616
treeaaba8503c176f01d259b33b59e3a84001a0939ce
parent48c28b17a9de54a402b92e0564f64afe4d3f83e5
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.

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]