public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97988] New: [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies
@ 2020-11-25 16:20 arthur.j.odwyer at gmail dot com
2021-08-17 8:36 ` [Bug c++/97988] " pinskia at gcc dot gnu.org
2023-06-09 14:36 ` ppalka at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2020-11-25 16:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97988
Bug ID: 97988
Summary: [C++20] Forward-declared class type declared inside
requires-expression gives weird inconsistencies
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: arthur.j.odwyer at gmail dot com
Target Milestone: ---
// https://godbolt.org/z/sxWY1f
template<class P>
concept C = requires (P ptr) { (struct D*)ptr; };
struct D {};
D d;
====
Clang accepts. GCC rejects; GCC's error messages imply that GCC is sometimes
treating `D` as a class template `template<class P> struct D` and sometimes
treating it as a normal class type, as if its internal representation is
inconsistent.
<source>:6:3: error: class template argument deduction failed:
6 | D d;
| ^
<source>:6:3: error: no matching function for call to 'D()'
<source>:3:40: note: candidate: 'template<class P> D()-> D'
3 | concept C = requires (P ptr) { (struct D*)ptr; };
| ^
<source>:3:40: note: template argument deduction/substitution failed:
<source>:6:3: note: couldn't deduce template parameter 'P'
6 | D d;
| ^
<source>:3:40: note: candidate: 'template<class P> D(D)-> D'
3 | concept C = requires (P ptr) { (struct D*)ptr; };
| ^
<source>:3:40: note: template argument deduction/substitution failed:
<source>:6:3: note: candidate expects 1 argument, 0 provided
6 | D d;
| ^
====
I can also make GCC segfault by trying to use `D` as an NTTP, but I think
that's essentially just a duplicate of #95159 #95291 #96123 #97749 etc., not
necessarily related to the rejects-invalid bug described here.
template<class P>
concept C = requires (P ptr) { (struct D*)ptr; };
struct D { constexpr D(); };
template<D d> struct S {};
S<1> s;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/97988] [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies
2020-11-25 16:20 [Bug c++/97988] New: [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies arthur.j.odwyer at gmail dot com
@ 2021-08-17 8:36 ` pinskia at gcc dot gnu.org
2023-06-09 14:36 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97988
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Keywords| |ice-on-invalid-code
Depends on| |12944
Last reconfirmed| |2021-08-17
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It seems like it is creating a struct D with the template argument in the
global namespace.
If I add struct D; at the very begining of the file, it all works.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12944
[Bug 12944] [meta-bug] C++ name-lookup problems
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/97988] [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies
2020-11-25 16:20 [Bug c++/97988] New: [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies arthur.j.odwyer at gmail dot com
2021-08-17 8:36 ` [Bug c++/97988] " pinskia at gcc dot gnu.org
@ 2023-06-09 14:36 ` ppalka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-06-09 14:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97988
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Seems to be fixed by r12-7997, so I suppose let's call this as dup of PR101677.
*** This bug has been marked as a duplicate of bug 101677 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-09 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 16:20 [Bug c++/97988] New: [C++20] Forward-declared class type declared inside requires-expression gives weird inconsistencies arthur.j.odwyer at gmail dot com
2021-08-17 8:36 ` [Bug c++/97988] " pinskia at gcc dot gnu.org
2023-06-09 14:36 ` 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).