public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter
@ 2020-07-17 1:41 johelegp at gmail dot com
2020-09-28 15:49 ` [Bug c++/96229] " ppalka at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2020-07-17 1:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
Bug ID: 96229
Summary: Invalid specialization accepted when also constrained
in base template template parameter
Product: gcc
Version: 10.1.0
URL: https://godbolt.org/z/W1zh9n
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: johelegp at gmail dot com
Target Milestone: ---
See https://godbolt.org/z/W1zh9n.
```C++
template <class T> concept Int = requires { T{0}; };
template <template <Int> class T> struct X { };
template <Int> /* ^~~ */ struct Y : X<Y> { };
struct Z { };
void f() { Y<Z> x; }
```
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96229] Invalid specialization accepted when also constrained in base template template parameter
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
@ 2020-09-28 15:49 ` ppalka at gcc dot gnu.org
2020-09-28 19:10 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-09-28 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-09-28
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96229] Invalid specialization accepted when also constrained in base template template parameter
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
2020-09-28 15:49 ` [Bug c++/96229] " ppalka at gcc dot gnu.org
@ 2020-09-28 19:10 ` ppalka at gcc dot gnu.org
2020-10-08 4:06 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-09-28 19:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96229] Invalid specialization accepted when also constrained in base template template parameter
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
2020-09-28 15:49 ` [Bug c++/96229] " ppalka at gcc dot gnu.org
2020-09-28 19:10 ` ppalka at gcc dot gnu.org
@ 2020-10-08 4:06 ` cvs-commit at gcc dot gnu.org
2020-10-13 15:45 ` cvs-commit at gcc dot gnu.org
2020-10-13 15:46 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-08 4:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:6b1b5c255f859e75a2d74ae58a011e846d87a277
commit r11-3713-g6b1b5c255f859e75a2d74ae58a011e846d87a277
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Oct 8 00:05:36 2020 -0400
c++: Set the constraints of a class type sooner [PR96229]
In the testcase below, during processing (at parse time) of Y's base
class X<Y>, convert_template_argument calls is_compatible_template_arg
to check if the template argument Y is no more constrained than the
parameter P. But at this point we haven't yet set Y's constraints, so
get_normalized_constraints_from_decl yields NULL_TREE as the normal form
and caches this result into the normalized_map.
We set Y's constraints later in cp_parser_class_specifier_1 but the
stale normal form in the normalized_map remains. This ultimately causes
us to miss the constraint failure for Y<Z> because according to the
cached normal form, Y is not constrained.
This patch fixes this issue by moving up the call to
associate_classtype_constraints so that we set constraints before we
start processing a class's bases.
gcc/cp/ChangeLog:
PR c++/96229
* parser.c (cp_parser_class_specifier_1): Move call to
associate_classtype_constraints from here to ...
(cp_parser_class_head): ... here.
* pt.c (is_compatible_template_arg): Correct documentation to
say "argument is _no_ more constrained than the parameter".
gcc/testsuite/ChangeLog:
PR c++/96229
* g++.dg/cpp2a/concepts-class2.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96229] Invalid specialization accepted when also constrained in base template template parameter
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
` (2 preceding siblings ...)
2020-10-08 4:06 ` cvs-commit at gcc dot gnu.org
@ 2020-10-13 15:45 ` cvs-commit at gcc dot gnu.org
2020-10-13 15:46 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-10-13 15:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:1e8cd9628dcaedbb96bd014e0865e1415484e84b
commit r10-8887-g1e8cd9628dcaedbb96bd014e0865e1415484e84b
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Oct 8 00:05:36 2020 -0400
c++: Set the constraints of a class type sooner [PR96229]
In the testcase below, during processing (at parse time) of Y's base
class X<Y>, convert_template_argument calls is_compatible_template_arg
to check if the template argument Y is no more constrained than the
parameter P. But at this point we haven't yet set Y's constraints, so
get_normalized_constraints_from_decl yields NULL_TREE as the normal form
and caches this result into the normalized_map.
We set Y's constraints later in cp_parser_class_specifier_1 but the
stale normal form in the normalized_map remains. This ultimately causes
us to miss the constraint failure for Y<Z> because according to the
cached normal form, Y is not constrained.
This patch fixes this issue by moving up the call to
associate_classtype_constraints so that we set constraints before we
start processing a class's bases.
gcc/cp/ChangeLog:
PR c++/96229
* parser.c (cp_parser_class_specifier_1): Move call to
associate_classtype_constraints from here to ...
(cp_parser_class_head): ... here.
* pt.c (is_compatible_template_arg): Correct documentation to
say "argument is _no_ more constrained than the parameter".
gcc/testsuite/ChangeLog:
PR c++/96229
* g++.dg/cpp2a/concepts-class2.C: New test.
(cherry picked from commit 6b1b5c255f859e75a2d74ae58a011e846d87a277)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96229] Invalid specialization accepted when also constrained in base template template parameter
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
` (3 preceding siblings ...)
2020-10-13 15:45 ` cvs-commit at gcc dot gnu.org
@ 2020-10-13 15:46 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-10-13 15:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.3
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 10.3+
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-13 15:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 1:41 [Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter johelegp at gmail dot com
2020-09-28 15:49 ` [Bug c++/96229] " ppalka at gcc dot gnu.org
2020-09-28 19:10 ` ppalka at gcc dot gnu.org
2020-10-08 4:06 ` cvs-commit at gcc dot gnu.org
2020-10-13 15:45 ` cvs-commit at gcc dot gnu.org
2020-10-13 15:46 ` 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).