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
* [Bug c++/111831] friend with requires keyword compilation error
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 ` pinskia at gcc dot gnu.org
2023-10-16 16:52 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111831
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
URL|https://github.com/user1095 |
|108/xl/blob/master/list.cpp |
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://github.com/user1095108/xl/blob/master/list.cpp
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/111831] friend with requires keyword compilation error
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
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 16:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111831
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 56121
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56121&action=edit
preprocessed source
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/111831] friend with requires keyword compilation error
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
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111831
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection,
| |needs-reduction,
| |rejects-valid
Host|Linux e5-2620v2 |
|6.5.7-arch1-1 #1 SMP |
|PREEMPT_DYNAMIC Tue, 10 Oct |
|2023 21:10:21 +0000 x86_64 |
|GNU/Linux |
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems to work on the trunk ...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/111831] friend with requires keyword compilation error
2023-10-16 12:00 [Bug c++/111831] New: friend with requires keyword compilation error janezz55 at gmail dot com
` (2 preceding siblings ...)
2023-10-16 16:53 ` pinskia at gcc dot gnu.org
@ 2023-10-16 18:33 ` ppalka at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-10-16 18:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111831
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
CC| |ppalka at gcc dot gnu.org
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like this is a dup of PR109751, which has been fixed for GCC 13.3 / 14.
A workaround for earlier GCC is to turn the problematic constrained hidden
friend into a template:
template <int = 0>
friend auto operator==(list const& l, list const& r)
...
This prevents GCC from overeagerly checking the function's constraints.
*** This bug has been marked as a duplicate of bug 109751 ***
^ 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).