public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> @ 2020-04-23 1:22 ` mpolacek at gcc dot gnu.org 2020-04-23 8:03 ` paolo.carlini at oracle dot com ` (3 subsequent siblings) 4 siblings, 0 replies; 5+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-04-23 1:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90320 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] 5+ messages in thread
* [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> 2020-04-23 1:22 ` [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly mpolacek at gcc dot gnu.org @ 2020-04-23 8:03 ` paolo.carlini at oracle dot com 2020-04-27 1:09 ` cvs-commit at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 5+ messages in thread From: paolo.carlini at oracle dot com @ 2020-04-23 8:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90320 --- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> --- Thanks Marek. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> 2020-04-23 1:22 ` [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly mpolacek at gcc dot gnu.org 2020-04-23 8:03 ` paolo.carlini at oracle dot com @ 2020-04-27 1:09 ` cvs-commit at gcc dot gnu.org 2020-04-27 1:11 ` [Bug c++/90320] [8/9 " mpolacek at gcc dot gnu.org 2020-05-13 17:31 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2020-04-27 1:09 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90320 --- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:feb801f62239528bca2cfb6c3abd70d434b69c0a commit r10-7979-gfeb801f62239528bca2cfb6c3abd70d434b69c0a Author: Marek Polacek <polacek@redhat.com> Date: Wed Apr 22 20:12:47 2020 -0400 c++: Explicit constructor called in copy-initialization [PR90320] This test is rejected with a bogus "use of deleted function" error starting with r225705 whereby convert_like_real/ck_base no longer sets LOOKUP_ONLYCONVERTING for user_conv_p conversions. This does not seem to be always correct. To recap, when we have something like T t = x where T is a class type and the type of x is not T or derived from T, we perform copy-initialization, something like: 1. choose a user-defined conversion to convert x to T, the result is a prvalue, 2. use this prvalue to direct-initialize t. In the second step, explicit constructors should be considered, since we're direct-initializing. This is what r225705 fixed. In this PR we are dealing with the first step, I think, where explicit constructors should be skipped. [over.match.copy] says "The converting constructors of T are candidate functions" which clearly eliminates explicit constructors. But we also have to copy-initialize the argument we are passing to such a converting constructor, and here we should disregard explicit constructors too. In this testcase we have V v = m; and we choose V::V(M) to convert m to V. But we wrongly choose the explicit M::M<M&>(M&) to copy-initialize the argument; it's a better match for a non-const lvalue than the implicit M::M(const M&) but because it's explicit, we shouldn't use it. When convert_like is processing the ck_user conversion -- the convfn is V::V(M) -- it can see that cand->flags contains LOOKUP_ONLYCONVERTING, but then when we're in build_over_call for this convfn, we have no way to pass the flag to convert_like for the argument 'm', because convert_like doesn't take flags. Fixed by creating a new conversion flag, copy_init_p, set in ck_base/ck_rvalue to signal that explicit constructors should be skipped. LOOKUP_COPY_PARM looks relevant, but again, it's a LOOKUP_* flag, so can't pass it to convert_like. DR 899 also seemed related, but that deals with direct-init contexts only. PR c++/90320 * call.c (struct conversion): Add copy_init_p. (standard_conversion): Set copy_init_p in ck_base and ck_rvalue if FLAGS demands LOOKUP_ONLYCONVERTING. (convert_like_real) <case ck_base>: If copy_init_p is set, or LOOKUP_ONLYCONVERTING into FLAGS. * g++.dg/cpp0x/explicit13.C: New test. * g++.dg/cpp0x/explicit14.C: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/90320] [8/9 Regression] Explicit constructor called implicitly [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2020-04-27 1:09 ` cvs-commit at gcc dot gnu.org @ 2020-04-27 1:11 ` mpolacek at gcc dot gnu.org 2020-05-13 17:31 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 5+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-04-27 1:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90320 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[8/9/10 Regression] |[8/9 Regression] Explicit |Explicit constructor called |constructor called |implicitly |implicitly --- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Fixed on trunk so far. I'm considering backporting the fix to 9 too. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/90320] [8/9 Regression] Explicit constructor called implicitly [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2020-04-27 1:11 ` [Bug c++/90320] [8/9 " mpolacek at gcc dot gnu.org @ 2020-05-13 17:31 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 5+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-05-13 17:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90320 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |FIXED --- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Actually, maybe not. But it's fixed in GCC 10. I can backport if anyone thinks it's important. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-13 17:31 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-90320-4@http.gcc.gnu.org/bugzilla/> 2020-04-23 1:22 ` [Bug c++/90320] [8/9/10 Regression] Explicit constructor called implicitly mpolacek at gcc dot gnu.org 2020-04-23 8:03 ` paolo.carlini at oracle dot com 2020-04-27 1:09 ` cvs-commit at gcc dot gnu.org 2020-04-27 1:11 ` [Bug c++/90320] [8/9 " mpolacek at gcc dot gnu.org 2020-05-13 17:31 ` 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).