public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type"
@ 2020-05-26 8:23 stefaan.deroeck at gmail dot com
2020-05-26 10:41 ` [Bug c++/95328] " stefaan.deroeck at gmail dot com
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: stefaan.deroeck at gmail dot com @ 2020-05-26 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Bug ID: 95328
Summary: structured binding of template type inside template
function is reported as "incomplete class type"
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: stefaan.deroeck at gmail dot com
Target Milestone: ---
A structured binding assignment of a template type inside a template function
seems to be reported as "incomplete class type".
Compiling below code apparently produces the warning (and thus failure with
-Werror) on all applicable GCC versions (gcc-7 segfaults, gcc-8 and up
including 11 reports the warning). Clang and intel compilers compile this
without warnings.
This is the minimal code with which I can reproduce the issue. Removal of any
of the templating, or replacing the return type of makeData() by "auto", gets
rid of the warning.
compilation flags: -std=c++17 -Werror
Reported error:
<source>: In function 'void func()':
<source>:14:8: error: structured binding refers to incomplete class type
'Data<int>' [-Werror]
14 | auto [a, b] = makeData<int>();
| ^~~~~~
cc1plus: all warnings being treated as errors
Code:
template <typename T>
struct Data
{
int a, b;
};
template <typename T>
Data<T> makeData()
{
return Data<T>();
}
template <class Anything>
void func()
{
auto [a, b] = makeData<int>();
}
int main() { func<int>(); }
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
@ 2020-05-26 10:41 ` stefaan.deroeck at gmail dot com
2020-05-26 13:31 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: stefaan.deroeck at gmail dot com @ 2020-05-26 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
--- Comment #1 from Stefaan De Roeck <stefaan.deroeck at gmail dot com> ---
During further development, I nevertheless did find a shorter snippet to
reproduce the issue:
template <typename T>
struct Data
{
int a, b;
};
template <class Anything>
void func()
{
auto [a, b] = Data<int>();
}
int main() { func<int>(); }
If there were a way to disable this specific warning(/error), that would help
too...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
2020-05-26 10:41 ` [Bug c++/95328] " stefaan.deroeck at gmail dot com
@ 2020-05-26 13:31 ` jakub at gcc dot gnu.org
2020-05-28 21:41 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-26 13:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 48606
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48606&action=edit
gcc11-pr95328.patch
Untested fix.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
2020-05-26 10:41 ` [Bug c++/95328] " stefaan.deroeck at gmail dot com
2020-05-26 13:31 ` jakub at gcc dot gnu.org
@ 2020-05-28 21:41 ` cvs-commit at gcc dot gnu.org
2020-06-05 13:50 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-28 21:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:3d8d5ddb539a5254c7ef83414377f4c74c7701d4
commit r11-706-g3d8d5ddb539a5254c7ef83414377f4c74c7701d4
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu May 28 23:40:54 2020 +0200
c++: Try to complete decomp types [PR95328]
Two years ago Paolo has added the
else if (processing_template_decl && !COMPLETE_TYPE_P (type))
pedwarn (...);
lines into cp_finish_decomp. For type dependent decl we punt much earlier,
but even for types which aren't type dependent COMPLETE_TYPE_P might be
false as this testcase shows, so this patch tries to complete_type first
(the reason for writing it that way is that it is then followed by another
else if and if complete_type returns error_mark_node, we shouldn't report
anything, as a bug should have been reported already.
2020-05-28 Jakub Jelinek <jakub@redhat.com>
PR c++/95328
* decl.c (cp_finish_decomp): Call complete_type before checking
COMPLETE_TYPE_P.
* g++.dg/cpp1z/decomp53.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (2 preceding siblings ...)
2020-05-28 21:41 ` cvs-commit at gcc dot gnu.org
@ 2020-06-05 13:50 ` jakub at gcc dot gnu.org
2020-06-14 10:07 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-05 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2020-06-05
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (3 preceding siblings ...)
2020-06-05 13:50 ` jakub at gcc dot gnu.org
@ 2020-06-14 10:07 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-14 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:808f30b0772733886cefe7dead50862c169bcb2b
commit r10-8295-g808f30b0772733886cefe7dead50862c169bcb2b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu May 28 23:40:54 2020 +0200
c++: Try to complete decomp types [PR95328]
Two years ago Paolo has added the
else if (processing_template_decl && !COMPLETE_TYPE_P (type))
pedwarn (...);
lines into cp_finish_decomp. For type dependent decl we punt much earlier,
but even for types which aren't type dependent COMPLETE_TYPE_P might be
false as this testcase shows, so this patch tries to complete_type first
(the reason for writing it that way is that it is then followed by another
else if and if complete_type returns error_mark_node, we shouldn't report
anything, as a bug should have been reported already.
2020-05-28 Jakub Jelinek <jakub@redhat.com>
PR c++/95328
* decl.c (cp_finish_decomp): Call complete_type before checking
COMPLETE_TYPE_P.
* g++.dg/cpp1z/decomp53.C: New test.
(cherry picked from commit 3d8d5ddb539a5254c7ef83414377f4c74c7701d4)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (4 preceding siblings ...)
2020-06-14 10:07 ` cvs-commit at gcc dot gnu.org
@ 2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:51 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 19:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:8efa945b308307fd9b0313705f5826a8499de405
commit r9-8900-g8efa945b308307fd9b0313705f5826a8499de405
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu May 28 23:40:54 2020 +0200
c++: Try to complete decomp types [PR95328]
Two years ago Paolo has added the
else if (processing_template_decl && !COMPLETE_TYPE_P (type))
pedwarn (...);
lines into cp_finish_decomp. For type dependent decl we punt much earlier,
but even for types which aren't type dependent COMPLETE_TYPE_P might be
false as this testcase shows, so this patch tries to complete_type first
(the reason for writing it that way is that it is then followed by another
else if and if complete_type returns error_mark_node, we shouldn't report
anything, as a bug should have been reported already.
2020-05-28 Jakub Jelinek <jakub@redhat.com>
PR c++/95328
* decl.c (cp_finish_decomp): Call complete_type before checking
COMPLETE_TYPE_P.
* g++.dg/cpp1z/decomp53.C: New test.
(cherry picked from commit 3d8d5ddb539a5254c7ef83414377f4c74c7701d4)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (5 preceding siblings ...)
2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
@ 2020-09-17 17:51 ` jakub at gcc dot gnu.org
2021-08-05 6:27 ` pinskia at gcc dot gnu.org
2021-08-05 6:30 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-17 17:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 8.5 in r8-10506-g4163fd72a0606199c4ab867fde0efdff6346d6f3 and by the
above commit for 9.4+ too.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (6 preceding siblings ...)
2020-09-17 17:51 ` jakub at gcc dot gnu.org
@ 2021-08-05 6:27 ` pinskia at gcc dot gnu.org
2021-08-05 6:30 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 6:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janniksilvanus at gmail dot com
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 86930 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95328] structured binding of template type inside template function is reported as "incomplete class type"
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
` (7 preceding siblings ...)
2021-08-05 6:27 ` pinskia at gcc dot gnu.org
@ 2021-08-05 6:30 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 6:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95328
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.2.0, 8.5.0, 9.4.0
Known to fail| |10.1.0, 8.4.0, 9.3.0
Target Milestone|--- |8.5
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-08-05 6:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 8:23 [Bug c++/95328] New: structured binding of template type inside template function is reported as "incomplete class type" stefaan.deroeck at gmail dot com
2020-05-26 10:41 ` [Bug c++/95328] " stefaan.deroeck at gmail dot com
2020-05-26 13:31 ` jakub at gcc dot gnu.org
2020-05-28 21:41 ` cvs-commit at gcc dot gnu.org
2020-06-05 13:50 ` jakub at gcc dot gnu.org
2020-06-14 10:07 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:22 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:51 ` jakub at gcc dot gnu.org
2021-08-05 6:27 ` pinskia at gcc dot gnu.org
2021-08-05 6:30 ` pinskia 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).