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

            Bug ID: 113074
           Summary: requires requires should be SFINAE
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jdapena at igalia dot com
  Target Milestone: ---

Created attachment 56904
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56904&action=edit
Test case from godbolt

Calling std::to_address in a requires requires function should be SFINAE.
Instead of it, it fails to compile.

This is breaking GCC build of Chromium in
https://chromium.googlesource.com/chromium/src.git/+/refs/tags/122.0.6193.2/mojo/public/cpp/bindings/type_converter.h#98
when the type does not support std::to_address because it fails to find
operator->.

Code is:
template <typename T, typename U>
  requires requires(const U& obj) {
    not std::is_pointer_v<U>;
    { mojo::ConvertTo<T>(std::to_address(obj)) } -> std::same_as<T>;
  }
inline T ConvertTo(const U& obj) {
  return mojo::ConvertTo<T>(std::to_address(obj));
}

The code is designed to only declare ConvertTo in case it can convert from
std::to_address result.

A possible test case is attached. This case fails in Clang with the expected
outcome (it fails to resolve to a valid call).

Reply via email to