public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94033] [10 Regression] is_trivially_copy_constructible<> fails with compiler error on complicated object with private default constructor Date: Thu, 12 Mar 2020 14:57:12 +0000 [thread overview] Message-ID: <bug-94033-4-KEixNx4wws@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-94033-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94033 --- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> --- I think it doesn't show up for gcc-9 because there are also std::tuple changes on master that make the bug show up. And I think what's happening is another instance of PR 41437. When std::optional<mutation> is instantiated it causes std::is_constructible<mutation> to be instantiated, but gives the wrong answer because of PR 41437. Later when the value of std::is_nothrow_default_constructible<mutation> is needed, the bad instantiation of is_constructible<mutation> is reused, which means that the first condition in the __and_ here is true (but shouldn't be) and so we try the second condition, which is ill-formed: /// is_nothrow_default_constructible template<typename _Tp> struct is_nothrow_default_constructible : public __and_<is_default_constructible<_Tp>, __is_nt_default_constructible_impl<_Tp>> { }; /home/jwakely/gcc/10/include/c++/10.0.1/type_traits:966:47: error: 'mutation::mutation()' is private within this context 966 | : public integral_constant<bool, noexcept(_Tp())> | ^~~~~ We should never try to construct _Tp() when it isn't default constructible. The cached bad value of is_constructible<mutation> makes us try to do something impossible. Lending weight to this theory is the fact that explicitly checking is_constructible_v<mutation> *before* instantiating optional<mutation> makes the bug go away: #include <optional> #include <tuple> template <bool B> struct abc {}; template <typename T> struct future : public abc<std::is_trivially_constructible<std::tuple<T>>::value> {}; class mutation { mutation(); friend class std::optional<mutation>; }; #ifdef FIX static_assert( !std::is_nothrow_default_constructible<mutation>::value ); #endif using mutation_opt = std::optional<mutation>; future<mutation_opt> foo(); template <typename Consumer> future<mutation_opt> consume_partitions() { return foo(); } future<mutation_opt> bar() { return consume_partitions<int>(); } future<mutation> zed(); future<mutation> apply_counter_update() { return zed(); } Define FIX to make the bug vanish.
next prev parent reply other threads:[~2020-03-12 14:57 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-94033-4@http.gcc.gnu.org/bugzilla/> 2020-03-07 19:54 ` [Bug libstdc++/94033] " rafael at espindo dot la 2020-03-11 12:01 ` [Bug libstdc++/94033] [10 Regression] " redi at gcc dot gnu.org 2020-03-11 12:04 ` redi at gcc dot gnu.org 2020-03-12 13:59 ` avi@cloudius-systems.com 2020-03-12 14:10 ` redi at gcc dot gnu.org 2020-03-12 14:15 ` avi@cloudius-systems.com 2020-03-12 14:20 ` redi at gcc dot gnu.org 2020-03-12 14:57 ` redi at gcc dot gnu.org [this message] 2020-03-12 16:38 ` redi at gcc dot gnu.org 2020-03-16 14:54 ` avi@cloudius-systems.com 2020-03-16 15:38 ` redi at gcc dot gnu.org 2020-03-16 16:07 ` redi at gcc dot gnu.org 2020-03-17 17:48 ` avi@cloudius-systems.com 2020-03-17 18:14 ` redi at gcc dot gnu.org 2020-03-18 23:20 ` cvs-commit at gcc dot gnu.org 2020-03-18 23:21 ` 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 2021-09-30 15:01 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-94033-4-KEixNx4wws@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).