public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
@ 2020-09-09 14:01 dushistov at mail dot ru
2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dushistov at mail dot ru @ 2020-09-09 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96999
Bug ID: 96999
Summary: regression: std::variant requires default constructor
with gcc 8-9, gcc 7.x and 10.x works
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dushistov at mail dot ru
Target Milestone: ---
For code bellow, gcc 9.3 from Ubuntu reports error:
```
In file included from /usr/include/c++/9/variant:36,
from test.cpp:1:
...
/usr/include/c++/9/type_traits:931:47: error: ‘Foo::Foo()’ is private within
this context
931 | : public integral_constant<bool, noexcept(_Tp())>
| ^~~~~
test.cpp:10:3: note: declared private here
10 | Foo() noexcept {}
| ^~~
```
gcc 8.x also reports error. gcc 7.x and 10.x works just fine:
```
#include <variant>
#include <string>
struct Foo {
public:
explicit Foo(int) noexcept {}
Foo(Foo &&) noexcept = default;
Foo &operator=(Foo &&) = default;
private:
Foo() noexcept {}
};
struct Boo {
public:
explicit Boo(int) noexcept {}
Boo(Boo &&) noexcept = default;
Boo &operator=(Boo &&) = default;
private:
Boo() noexcept {}
};
template<bool X>
std::variant<Foo, Boo> g(int v, int x) {
return v == 0 ? std::variant<Foo, Boo>{Foo{x}} :
std::variant<Foo, Boo>{Boo{x}};
}
int main()
{
std::variant<std::variant<Foo, Boo>, std::string> err{std::string("aaa")};
}
```
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/96999] [8/9 Regression] std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
@ 2020-09-09 15:12 ` redi at gcc dot gnu.org
2020-09-11 10:09 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-09 15:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96999
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |8.4.0, 9.3.0
Last reconfirmed| |2020-09-09
Status|UNCONFIRMED |ASSIGNED
Keywords| |rejects-valid
Known to work| |10.1.0, 11.0, 7.4.0
Ever confirmed|0 |1
Target Milestone|--- |8.5
Component|c++ |libstdc++
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Summary|regression: std::variant |[8/9 Regression]
|requires default |std::variant requires
|constructor with gcc 8-9, |default constructor with
|gcc 7.x and 10.x works |gcc 8-9, gcc 7.x and 10.x
| |works
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems to be a similar problem to PR 94033, and is fixed by its r10-7270
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/96999] [8/9 Regression] std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
@ 2020-09-11 10:09 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:53 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:56 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-11 10:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96999
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:6d06c17e9f470f4a2d7e41ca6f3a8b36c729dc6a
commit r9-8860-g6d06c17e9f470f4a2d7e41ca6f3a8b36c729dc6a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 18 23:19:12 2020 +0000
libstdc++: Fix is_trivially_constructible (PR 94033)
This attempts to make is_nothrow_constructible more robust (and
efficient to compile) by not depending on is_constructible. Instead the
__is_constructible intrinsic is used directly. The helper class
__is_nt_constructible_impl which checks whether the construction is
non-throwing now takes a bool template parameter that is substituted by
the result of the instrinsic. This fixes the reported bug by not using
the already-instantiated (and incorrect) value of std::is_constructible.
I don't think it really fixes the problem in general, because
std::is_nothrow_constructible itself could already have been
instantiated in a context where it gives the wrong result. A proper fix
needs to be done in the compiler.
Backported to the gcc-8 and gcc-9 branches to fix PR 96999.
PR libstdc++/94033
* include/std/type_traits (__is_nt_default_constructible_atom):
Remove.
(__is_nt_default_constructible_impl): Remove.
(__is_nothrow_default_constructible_impl): Remove.
(__is_nt_constructible_impl): Add bool template parameter. Adjust
partial specializations.
(__is_nothrow_constructible_impl): Replace class template with
alias
template.
(is_nothrow_default_constructible): Derive from alias template
__is_nothrow_constructible_impl instead of
__is_nothrow_default_constructible_impl.
* testsuite/20_util/is_nothrow_constructible/94003.cc: New test.
(cherry picked from commit b3341826531e80e02f194460b4fbe1b0541c0463)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/96999] [8/9 Regression] std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
2020-09-11 10:09 ` cvs-commit at gcc dot gnu.org
@ 2020-09-11 10:53 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:56 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-11 10:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96999
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:1521433e2b6bff583b227fe391fe9dcf02f6000e
commit r8-10445-g1521433e2b6bff583b227fe391fe9dcf02f6000e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 18 23:19:12 2020 +0000
libstdc++: Fix is_trivially_constructible (PR 94033)
This attempts to make is_nothrow_constructible more robust (and
efficient to compile) by not depending on is_constructible. Instead the
__is_constructible intrinsic is used directly. The helper class
__is_nt_constructible_impl which checks whether the construction is
non-throwing now takes a bool template parameter that is substituted by
the result of the instrinsic. This fixes the reported bug by not using
the already-instantiated (and incorrect) value of std::is_constructible.
I don't think it really fixes the problem in general, because
std::is_nothrow_constructible itself could already have been
instantiated in a context where it gives the wrong result. A proper fix
needs to be done in the compiler.
Backported to the gcc-8 and gcc-9 branches to fix PR 96999.
PR libstdc++/94033
* include/std/type_traits (__is_nt_default_constructible_atom):
Remove.
(__is_nt_default_constructible_impl): Remove.
(__is_nothrow_default_constructible_impl): Remove.
(__is_nt_constructible_impl): Add bool template parameter. Adjust
partial specializations.
(__is_nothrow_constructible_impl): Replace class template with
alias
template.
(is_nothrow_default_constructible): Derive from alias template
__is_nothrow_constructible_impl instead of
__is_nothrow_default_constructible_impl.
* testsuite/20_util/is_nothrow_constructible/94003.cc: New test.
(cherry picked from commit b3341826531e80e02f194460b4fbe1b0541c0463)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/96999] [8/9 Regression] std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
` (2 preceding siblings ...)
2020-09-11 10:53 ` cvs-commit at gcc dot gnu.org
@ 2020-09-11 10:56 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-11 10:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96999
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Should be fixed for 8.5 and 9.4, thanks for the report.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-11 10:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 14:01 [Bug c++/96999] New: regression: std::variant requires default constructor with gcc 8-9, gcc 7.x and 10.x works dushistov at mail dot ru
2020-09-09 15:12 ` [Bug libstdc++/96999] [8/9 Regression] " redi at gcc dot gnu.org
2020-09-11 10:09 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:53 ` cvs-commit at gcc dot gnu.org
2020-09-11 10:56 ` redi 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).