public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113074] New: requires requires should be SFINAE
@ 2023-12-18 21:16 jdapena at igalia dot com
  2023-12-18 22:57 ` [Bug libstdc++/113074] " pinskia at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: jdapena at igalia dot com @ 2023-12-18 21:16 UTC (permalink / raw)
  To: gcc-bugs

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).

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-02-15  8:39 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 21:16 [Bug c++/113074] New: requires requires should be SFINAE jdapena at igalia dot com
2023-12-18 22:57 ` [Bug libstdc++/113074] " pinskia at gcc dot gnu.org
2023-12-18 23:00 ` pinskia at gcc dot gnu.org
2023-12-18 23:05 ` pinskia at gcc dot gnu.org
2023-12-18 23:07 ` [Bug libstdc++/113074] std::to_address should be SFINAE safe pinskia at gcc dot gnu.org
2023-12-18 23:21 ` pinskia at gcc dot gnu.org
2023-12-19  4:09 ` de34 at live dot cn
2023-12-20  8:28 ` redi at gcc dot gnu.org
2024-02-07 20:11 ` pkasting at google dot com
2024-02-07 21:52 ` redi at gcc dot gnu.org
2024-02-07 21:59 ` pkasting at google dot com
2024-02-07 22:07 ` redi at gcc dot gnu.org
2024-02-07 22:14 ` redi at gcc dot gnu.org
2024-02-07 22:23 ` redi at gcc dot gnu.org
2024-02-14 17:25 ` pkasting at google dot com
2024-02-14 19:57 ` redi at gcc dot gnu.org
2024-02-14 20:00 ` redi at gcc dot gnu.org
2024-02-14 21:37 ` pkasting at google dot com
2024-02-15  8:38 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).