public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111831] New: friend with requires keyword compilation error
@ 2023-10-16 12:00 janezz55 at gmail dot com
  2023-10-16 16:47 ` [Bug c++/111831] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: janezz55 at gmail dot com @ 2023-10-16 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111831
           Summary: friend with requires keyword compilation error
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janezz55 at gmail dot com
  Target Milestone: ---

If I compile list.cpp with:

g++ -std=c++20 list.cpp -o l

friend auto operator==(list const& l, list const& r)
  noexcept(noexcept(
      std::equal(l.begin(), l.end(), r.begin(), r.end())
    )
  )
  requires(requires{std::equal(l.begin(), l.end(), r.begin(), r.end());})
{
  return std::equal(l.begin(), l.end(), r.begin(), r.end());
}

gcc-13.2.1 will respond with a compilation error:

error: no match for 'operator==' (operand types are 'xl::list<int>' and
'xl::list<int>')
   51 |   std::cout << a.size() << " " << b.size() << " " << (a == b) <<
std::endl;
      |                                                       ~ ^~ ~
      |                                                       |    |
      |                                                       |    list<[...]>
      |                                                       list<[...]>

bug clang-16.0.6 won't. I think the bug is related to the friend declaration. I
have prepared an example:

https://github.com/user1095108/xl/blob/master/list.cpp

The relevant requires inside list.hpp is commented out, since the requires
serves no purpose at all in this case. Please uncomment, if you decide to
investigate.

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

end of thread, other threads:[~2023-10-16 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16 12:00 [Bug c++/111831] New: friend with requires keyword compilation error janezz55 at gmail dot com
2023-10-16 16:47 ` [Bug c++/111831] " pinskia at gcc dot gnu.org
2023-10-16 16:52 ` pinskia at gcc dot gnu.org
2023-10-16 16:53 ` pinskia at gcc dot gnu.org
2023-10-16 18:33 ` ppalka 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).