This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/85765] Missing SFINAE in default template argument
- From: "ensadc at mailnesia dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 13 May 2018 11:08:22 +0000
- Subject: [Bug c++/85765] Missing SFINAE in default template argument
- Auto-submitted: auto-generated
- References: <bug-85765-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85765
ensadc at mailnesia dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
--- Comment #1 from ensadc at mailnesia dot com ---
This bug can be triggered by libstdc++'s `std::bind`, even when user code does
not use `volatile` (in which case the error is quite hard to discern):
----
#include <functional>
#include <initializer_list>
#include <utility>
struct begin_fn {
template<class T, class I = decltype(begin(std::declval<T&>())),
decltype(*I(), 0) = 0>
static I impl_(T& t, long) noexcept(noexcept(begin(t))) { return begin(t);
}
template<class T>
auto operator()(T& t) noexcept(noexcept(impl_(t, 0))) -> decltype(impl_(t,
0)) { return impl_(t, 0); }
};
std::initializer_list<int> x = {1};
auto a = std::bind(begin_fn{}, x)(); // error, even though begin_fn{}(x) is
fine
----
Similar pattern is used by range-v3 and has caused their example failing to
build with g++ 8.1. See https://github.com/ericniebler/range-v3/issues/826