public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97340] New: Spurious rejection of member variable template of reference type
@ 2020-10-08 16:36 herring at lanl dot gov
2020-10-08 17:15 ` [Bug c++/97340] " mpolacek at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: herring at lanl dot gov @ 2020-10-08 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
Bug ID: 97340
Summary: Spurious rejection of member variable template of
reference type
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: herring at lanl dot gov
Target Milestone: ---
In many recent versions of GCC, the following valid code
struct A {
template<class>
static constexpr const int &x=0;
};
template<class T=void>
struct B {
static constexpr int y=A::template x<int>;
};
template struct B<>;
produces
error: ''indirect_ref' not supported by dump_decl<declaration error>' is not a
template [-fpermissive]
7 | static constexpr int y=A::template x<int>;
| ~~~~~~~~~~~~^~~~~~
The 'template' after '::' here is unnecessary; removing it avoids the error,
but the error also appears if A is a class template (so that it's necessary to
write "A<T>::template x<int>"). Making A::x not be a reference also avoids the
error, as does referring to it from a non-templated context.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/97340] Spurious rejection of member variable template of reference type
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
@ 2020-10-08 17:15 ` mpolacek at gcc dot gnu.org
2020-10-09 8:08 ` marxin at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-10-08 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-10-08
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/97340] Spurious rejection of member variable template of reference type
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
2020-10-08 17:15 ` [Bug c++/97340] " mpolacek at gcc dot gnu.org
@ 2020-10-09 8:08 ` marxin at gcc dot gnu.org
2023-05-17 14:45 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-09 8:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
If I see correctly, it started with r6-2648-gdc062b4986328bfe.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/97340] Spurious rejection of member variable template of reference type
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
2020-10-08 17:15 ` [Bug c++/97340] " mpolacek at gcc dot gnu.org
2020-10-09 8:08 ` marxin at gcc dot gnu.org
@ 2023-05-17 14:45 ` ppalka at gcc dot gnu.org
2023-05-19 13:40 ` cvs-commit at gcc dot gnu.org
2023-05-19 13:41 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-17 14:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
CC| |ppalka at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=108848
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
We accept the original testcase (where A is not a template) since
r13-6380-gd3d205ab440886, but we still incorrectly reject the version where A
is a template:
template<class>
struct A {
template<class>
static constexpr const int &x=0;
};
template<class T>
struct B {
static constexpr int y=A<T>::template x<int>;
};
template struct B<void>;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/97340] Spurious rejection of member variable template of reference type
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
` (2 preceding siblings ...)
2023-05-17 14:45 ` ppalka at gcc dot gnu.org
@ 2023-05-19 13:40 ` cvs-commit at gcc dot gnu.org
2023-05-19 13:41 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-19 13:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
--- Comment #4 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:ef8926d23a458560b8e9be1a76cf29ddcb87ec2a
commit r14-997-gef8926d23a458560b8e9be1a76cf29ddcb87ec2a
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri May 19 09:40:16 2023 -0400
c++: scoped variable template-id of reference type [PR97340]
lookup_and_finish_template_variable calls convert_from_reference, which
means for a variable template-id of reference type the function wraps
the corresponding VAR_DECL in an INDIRECT_REF. But the downstream logic
of two callers, tsubst_qualified_id and finish_class_member_access_expr,
expect a DECL_P result and this unexpected INDIRECT_REF leads to an ICE
resolving such a (dependently scoped) template-id as in the first testcase.
(Note these two callers eventually call convert_from_reference on the
result anyway, so calling it earlier seems redundant in this case.)
This patch fixes this by pulling out the convert_from_reference call
from lookup_and_finish_template_variable and into the callers that
actually need it, which turns out to only be tsubst_copy_and_build
(if we got rid of the call there we'd mishandle the second testcase).
PR c++/97340
gcc/cp/ChangeLog:
* pt.cc (lookup_and_finish_template_variable): Don't call
convert_from_reference.
(tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Call
convert_from_reference on the result of
lookup_and_finish_template_variable.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/var-templ80.C: New test.
* g++.dg/cpp1y/var-templ81.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/97340] Spurious rejection of member variable template of reference type
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
` (3 preceding siblings ...)
2023-05-19 13:40 ` cvs-commit at gcc dot gnu.org
@ 2023-05-19 13:41 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-19 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97340
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |14.0
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |RESOLVED
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-05-19 13:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 16:36 [Bug c++/97340] New: Spurious rejection of member variable template of reference type herring at lanl dot gov
2020-10-08 17:15 ` [Bug c++/97340] " mpolacek at gcc dot gnu.org
2020-10-09 8:08 ` marxin at gcc dot gnu.org
2023-05-17 14:45 ` ppalka at gcc dot gnu.org
2023-05-19 13:40 ` cvs-commit at gcc dot gnu.org
2023-05-19 13:41 ` 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).