This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/85765] Missing SFINAE in default template argument


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]