public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature
@ 2023-06-07 16:55 danakj at orodu dot net
2023-06-07 17:00 ` [Bug c++/110160] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: danakj at orodu dot net @ 2023-06-07 16:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110160
Bug ID: 110160
Summary: g++ rejects concept as cyclical with non-matching
function signature
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: danakj at orodu dot net
Target Milestone: ---
Godbolt: https://godbolt.org/z/d4PhfMqvq
Code:
```
#include <sstream>
#include <string>
template <class T>
concept StreamCanReceiveString = requires(T& t, std::string s) {
{ t << s };
};
struct NotAStream {};
struct UnrelatedType {};
template <StreamCanReceiveString S>
S& operator<<(S& s, UnrelatedType) {
return s;
}
static_assert(!StreamCanReceiveString<NotAStream>);
static_assert(StreamCanReceiveString<std::stringstream>);
```
What happens here is GCC fails to be able to resolve the expression
`StreamCanReceiveString<NotAStream>`.
1. StreamCanReceiveString<NotAStream> tries to do NotAStream << std::string.
2. There is a templated operator<< that takes `StreamCanReceiveString` and
`UnrelatedType`
3. Since `UnrelatedType` is not std::string, this is not an overload candidate.
4. Clang and MSVC therefore do not try to recursively solve
`StreamCanReceiveString<NotAStream>` and reject the code. But GCC tries to
solve the concept and then fails due to recursion.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110160] g++ rejects concept as cyclical with non-matching function signature
2023-06-07 16:55 [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature danakj at orodu dot net
@ 2023-06-07 17:00 ` pinskia at gcc dot gnu.org
2023-06-07 17:37 ` danakj at orodu dot net
2023-06-07 18:25 ` danakj at orodu dot net
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-07 17:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110160
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99599
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is a dup of bug 99599, specifically bug 99599 comment #2 .
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110160] g++ rejects concept as cyclical with non-matching function signature
2023-06-07 16:55 [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature danakj at orodu dot net
2023-06-07 17:00 ` [Bug c++/110160] " pinskia at gcc dot gnu.org
@ 2023-06-07 17:37 ` danakj at orodu dot net
2023-06-07 18:25 ` danakj at orodu dot net
2 siblings, 0 replies; 4+ messages in thread
From: danakj at orodu dot net @ 2023-06-07 17:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110160
--- Comment #2 from danakj at orodu dot net ---
Ugh, yeah, I guess it is. It means you can't redirect through a template
function that uses concepts with G++.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/110160] g++ rejects concept as cyclical with non-matching function signature
2023-06-07 16:55 [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature danakj at orodu dot net
2023-06-07 17:00 ` [Bug c++/110160] " pinskia at gcc dot gnu.org
2023-06-07 17:37 ` danakj at orodu dot net
@ 2023-06-07 18:25 ` danakj at orodu dot net
2 siblings, 0 replies; 4+ messages in thread
From: danakj at orodu dot net @ 2023-06-07 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110160
danakj at orodu dot net changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from danakj at orodu dot net ---
Okay I've got a workaround based on
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99599#c6. It's probably worse for
compile times, but it is what it is.
Thanks for the link.
*** This bug has been marked as a duplicate of bug 99599 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-07 18:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 16:55 [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature danakj at orodu dot net
2023-06-07 17:00 ` [Bug c++/110160] " pinskia at gcc dot gnu.org
2023-06-07 17:37 ` danakj at orodu dot net
2023-06-07 18:25 ` danakj at orodu dot net
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).