public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context @ 2020-12-19 5:58 ensadc at mailnesia dot com 2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: ensadc at mailnesia dot com @ 2020-12-19 5:58 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 Bug ID: 98388 Summary: Throwing move-only parameter results in hard error in SFINAE context Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ensadc at mailnesia dot com Target Milestone: --- https://godbolt.org/z/xn8fYz ==== struct moveonly { moveonly() = default; moveonly(moveonly&&) = default; }; template<class T> constexpr auto is_throwable(T t) -> decltype(throw t, true) { return true; } template<class T> constexpr bool is_throwable(...) { return false; } constexpr bool b = is_throwable<moveonly>(moveonly{}); ==== <source>: In substitution of 'template<class T> constexpr decltype ((<throw-expression>, true)) is_throwable(T) [with T = moveonly]': <source>:13:43: required from here <source>:7:46: error: use of deleted function 'constexpr moveonly::moveonly(const moveonly&)' 7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) { | ^~~~~~~ <source>:1:8: note: 'constexpr moveonly::moveonly(const moveonly&)' is implicitly declared as deleted because 'moveonly' declares a move constructor or move assignment operator 1 | struct moveonly { | ^~~~~~~~ <source>:7:52: note: in thrown expression 7 | constexpr auto is_throwable(T t) -> decltype(throw t, true) { | ^ ==== I'm not sure what the value of `b` should be, but I believe that it should not be a hard error. (Clang and MSVC initialize `b` to `true`.) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98388] Throwing move-only parameter results in hard error in SFINAE context 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com @ 2021-02-04 11:04 ` redi at gcc dot gnu.org 2024-02-07 15:34 ` mpolacek at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: redi at gcc dot gnu.org @ 2021-02-04 11:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-02-04 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98388] Throwing move-only parameter results in hard error in SFINAE context 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com 2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org @ 2024-02-07 15:34 ` mpolacek at gcc dot gnu.org 2024-02-09 21:38 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-02-07 15:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Status|NEW |ASSIGNED CC| |mpolacek at gcc dot gnu.org ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98388] Throwing move-only parameter results in hard error in SFINAE context 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com 2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org 2024-02-07 15:34 ` mpolacek at gcc dot gnu.org @ 2024-02-09 21:38 ` cvs-commit at gcc dot gnu.org 2024-02-09 21:43 ` mpolacek at gcc dot gnu.org 2024-02-16 17:13 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2024-02-09 21:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 --- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:3a3e0f1b46a3ad71ebeedc419393e3a36f1ce6db commit r14-8903-g3a3e0f1b46a3ad71ebeedc419393e3a36f1ce6db Author: Marek Polacek <polacek@redhat.com> Date: Tue Feb 6 15:35:16 2024 -0500 c++: make build_throw SFINAE-friendly [PR98388] Here the problem is that we give hard errors while substituting template parameters during overload resolution of is_throwable which has an invalid throw in decltype. The backtrace shows that fn_type_unification -> instantiate_template -> tsubst* passes complain=0 as expected, but build_throw doesn't have a complain parameter. So let's add one. Also remove a redundant local variable which I should have removed in my P2266 patch. There's still one problem for which I opened <https://gcc.gnu.org/PR113853>. We need to patch up treat_lvalue_as_rvalue_p and remove the dg-bogus. Thanks to Patrick for notifying me of this PR. This doesn't fully fix 113789; there I think I'll have to figure our why a candidate wasn't discarded from the overload set. PR c++/98388 gcc/cp/ChangeLog: * coroutines.cc (coro_rewrite_function_body): Pass tf_warning_or_error to build_throw. (morph_fn_to_coro): Likewise. * cp-tree.h (build_throw): Adjust. * except.cc (expand_end_catch_block): Pass tf_warning_or_error to build_throw. (build_throw): Add a tsubst_flags_t parameter. Use it. Remove redundant variable. Guard an inform call. * parser.cc (cp_parser_throw_expression): Pass tf_warning_or_error to build_throw. * pt.cc (tsubst_expr) <case THROW_EXPR>: Pass complain to build_throw. libcc1/ChangeLog: * libcp1plugin.cc (plugin_build_unary_expr): Pass tf_error to build_throw. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/sfinae69.C: New test. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98388] Throwing move-only parameter results in hard error in SFINAE context 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com ` (2 preceding siblings ...) 2024-02-09 21:38 ` cvs-commit at gcc dot gnu.org @ 2024-02-09 21:43 ` mpolacek at gcc dot gnu.org 2024-02-16 17:13 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-02-09 21:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=113853 --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Mostly fixed, but bug 113853 remains. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/98388] Throwing move-only parameter results in hard error in SFINAE context 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com ` (3 preceding siblings ...) 2024-02-09 21:43 ` mpolacek at gcc dot gnu.org @ 2024-02-16 17:13 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2024-02-16 17:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98388 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Should be fixed now. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-16 17:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-19 5:58 [Bug c++/98388] New: Throwing move-only parameter results in hard error in SFINAE context ensadc at mailnesia dot com 2021-02-04 11:04 ` [Bug c++/98388] " redi at gcc dot gnu.org 2024-02-07 15:34 ` mpolacek at gcc dot gnu.org 2024-02-09 21:38 ` cvs-commit at gcc dot gnu.org 2024-02-09 21:43 ` mpolacek at gcc dot gnu.org 2024-02-16 17:13 ` mpolacek 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).