public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type
@ 2022-08-14 10:52 jlame646 at gmail dot com
2022-08-14 16:53 ` [Bug c++/106613] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jlame646 at gmail dot com @ 2022-08-14 10:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106613
Bug ID: 106613
Summary: GCC rejects valid program involving std::invariant
saying incomplete type
Product: gcc
Version: 12.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following valid(afaik) program is rejected by gcc.
https://godbolt.org/z/e73Yf4s47
```
#include <variant>
struct LiteralExpr
{
int value;
};
template <typename T>
struct BaseSpace
{
struct AddExpr;
struct AddExprBox
{
const AddExpr &_impl;
public:
AddExprBox(const AddExpr &obj) {}
};
using Expr = std::variant<AddExprBox, LiteralExpr>;
struct AddExpr
{
std::variant<AddExprBox, LiteralExpr> lhs; // error:
'BaseSpace<T>::AddExpr::lhs' has incomplete type
};
};
auto main() -> int
{
auto expr = BaseSpace<int>::Expr(LiteralExpr{2});
}
```
The error says:
```
error: 'BaseSpace<T>::AddExpr::lhs' has incomplete type
22 | std::variant<AddExprBox, LiteralExpr> lhs;
| ^~~
In file included from <source>:1:
/opt/compiler-explorer/gcc-12.1.0/include/c++/12.1.0/variant:1336:11: note:
declaration of 'class std::variant<BaseSpace<int>::AddExprBox, LiteralExpr>'
1336 | class variant
| ^~~~~~~
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106613] GCC rejects valid program involving std::invariant saying incomplete type
2022-08-14 10:52 [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type jlame646 at gmail dot com
@ 2022-08-14 16:53 ` pinskia at gcc dot gnu.org
2022-08-15 3:45 ` jlame646 at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-14 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106613
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang rejects it with the same error message.
Both GCC and clang are correct because the inner types are not complete until
after the outer type is complete.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106613] GCC rejects valid program involving std::invariant saying incomplete type
2022-08-14 10:52 [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type jlame646 at gmail dot com
2022-08-14 16:53 ` [Bug c++/106613] " pinskia at gcc dot gnu.org
@ 2022-08-15 3:45 ` jlame646 at gmail dot com
2022-08-15 4:53 ` pinskia at gcc dot gnu.org
2022-08-15 4:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jlame646 at gmail dot com @ 2022-08-15 3:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106613
--- Comment #2 from Jason Liam <jlame646 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> clang rejects it with the same error message.
>
> Both GCC and clang are correct because the inner types are not complete
> until after the outer type is complete.
I don't think what you said about " inner types are not complete until after
the outer type is complete" is true.
In particular, the following program is well-formed. Note in the below program
the nested type named `A` is complete when its `};` is encountered and not when
the containing class `C`'s `};` is encountered as opposed to your claim.
```
struct C
{
struct A
{
};
static constexpr A a{}; //this is fine because A is complete here as
opposed to Andrew's claim
};
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106613] GCC rejects valid program involving std::invariant saying incomplete type
2022-08-14 10:52 [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type jlame646 at gmail dot com
2022-08-14 16:53 ` [Bug c++/106613] " pinskia at gcc dot gnu.org
2022-08-15 3:45 ` jlame646 at gmail dot com
@ 2022-08-15 4:53 ` pinskia at gcc dot gnu.org
2022-08-15 4:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-15 4:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106613
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|INVALID |DUPLICATE
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 96645.
*** This bug has been marked as a duplicate of bug 96645 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/106613] GCC rejects valid program involving std::invariant saying incomplete type
2022-08-14 10:52 [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type jlame646 at gmail dot com
` (2 preceding siblings ...)
2022-08-15 4:53 ` pinskia at gcc dot gnu.org
@ 2022-08-15 4:57 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-08-15 4:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106613
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=102199
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also see PR 102199.
Also see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88165#c10 (which
references when the inner class type is complete).
This is one of the dark corners of C++ which have issues with many things.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-15 4:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14 10:52 [Bug c++/106613] New: GCC rejects valid program involving std::invariant saying incomplete type jlame646 at gmail dot com
2022-08-14 16:53 ` [Bug c++/106613] " pinskia at gcc dot gnu.org
2022-08-15 3:45 ` jlame646 at gmail dot com
2022-08-15 4:53 ` pinskia at gcc dot gnu.org
2022-08-15 4:57 ` 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).