public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98642] New: wrong "use of deleted function" error
@ 2021-01-12 19:51 mpolacek at gcc dot gnu.org
  2021-01-12 19:52 ` [Bug c++/98642] [10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-12 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

            Bug ID: 98642
           Summary: wrong "use of deleted function" error
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

class base {
public:
  base(void) {};
  base(base &&) = delete;
};

class foo : public base {
};

template<typename C>
inline C &bar(void)
{
  static C c{};
  return c;
}

const foo &baz(void)
{
  return bar<const foo>();
}

is rejected since r11-2704 in C++17.  clang++/EDG accept this.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10/11 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
@ 2021-01-12 19:52 ` mpolacek at gcc dot gnu.org
  2021-01-12 19:56 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-12 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong "use of deleted       |[10/11 Regression] wrong
                   |function" error             |"use of deleted function"
                   |                            |error
           Priority|P3                          |P1
   Target Milestone|---                         |10.3
           Keywords|                            |rejects-valid

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10/11 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
  2021-01-12 19:52 ` [Bug c++/98642] [10/11 Regression] " mpolacek at gcc dot gnu.org
@ 2021-01-12 19:56 ` mpolacek at gcc dot gnu.org
  2021-01-12 20:55 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-01-12 19:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
$ ./cc1plus -quiet 98642.C
98642.C: In instantiation of ‘C& bar() [with C = const foo]’:
98642.C:19:25:   required from here
98642.C:13:12: error: use of deleted function ‘base::base(base&&)’
   13 |   static C c{};
      |            ^
98642.C:4:3: note: declared here
    4 |   base(base &&) = delete;
      |   ^~~~

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10/11 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
  2021-01-12 19:52 ` [Bug c++/98642] [10/11 Regression] " mpolacek at gcc dot gnu.org
  2021-01-12 19:56 ` mpolacek at gcc dot gnu.org
@ 2021-01-12 20:55 ` jason at gcc dot gnu.org
  2021-01-15 18:57 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2021-01-12 20:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
   Last reconfirmed|                            |2021-01-12
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10/11 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-12 20:55 ` jason at gcc dot gnu.org
@ 2021-01-15 18:57 ` cvs-commit at gcc dot gnu.org
  2021-01-15 19:12 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-15 18:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:d75199f782348bfc401f925b60f33ffc9822b7cc

commit r11-6736-gd75199f782348bfc401f925b60f33ffc9822b7cc
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 13 13:27:06 2021 -0500

    c++: Avoid redundant copy in {} init [PR98642]

    Here, initializing from { } implies a call to the default constructor for
    base.  We were then seeing that we're initializing a base subobject, so we
    tried to copy the result of that call.  This is clearly wrong; we should
    initialize the base directly from its default constructor.

    This patch does a lot of refactoring of unsafe_copy_elision_p and adds
    make_safe_copy_elision that will also try to do the base constructor
    rewriting from the last patch.

    gcc/cp/ChangeLog:

            PR c++/98642
            * call.c (unsafe_return_slot_p): Return int.
            (init_by_return_slot_p): Split out from...
            (unsafe_copy_elision_p): ...here.
            (unsafe_copy_elision_p_opt): New name for old meaning.
            (build_over_call): Adjust.
            (make_safe_copy_elision): New.
            * typeck2.c (split_nonconstant_init_1): Elide copy from safe
            list-initialization.
            * cp-tree.h: Adjust.

    gcc/testsuite/ChangeLog:

            PR c++/98642
            * g++.dg/cpp1z/elide5.C: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10/11 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-15 18:57 ` cvs-commit at gcc dot gnu.org
@ 2021-01-15 19:12 ` jason at gcc dot gnu.org
  2021-01-27  9:34 ` [Bug c++/98642] [10 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2021-01-15 19:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 49977
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49977&action=edit
possible patch to elide more copies

This implements a suggestion I made in
https://github.com/itanium-cxx-abi/cxx-abi/issues/107

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-01-15 19:12 ` jason at gcc dot gnu.org
@ 2021-01-27  9:34 ` rguenth at gcc dot gnu.org
  2021-01-27  9:36 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-27  9:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |needs-bisection
      Known to work|                            |10.2.0
      Known to fail|                            |10.2.1

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed it broke on the GCC 10 branch after the GCC 10.2 release which
worked,
thus indeed P1 but only is rejected with -std=c++17 not with the default -std
level.

What broke it on the branch?  (maybe reversion is a better fix there?)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-01-27  9:34 ` [Bug c++/98642] [10 " rguenth at gcc dot gnu.org
@ 2021-01-27  9:36 ` rguenth at gcc dot gnu.org
  2021-01-29 16:00 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-01-27  9:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
So obviously that was

2020-12-23  Jason Merrill  <jason@redhat.com>

        PR c++/90254
        PR c++/93711
        * cp-tree.h (unsafe_return_slot_p): Declare.
        * call.c (is_base_field_ref): Rename to unsafe_return_slot_p.
        (build_over_call): Check unsafe_return_slot_p.
        (build_special_member_call): Likewise.
        * init.c (expand_default_init): Likewise.
        * typeck2.c (split_nonconstant_init_1): Likewise.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-01-27  9:36 ` rguenth at gcc dot gnu.org
@ 2021-01-29 16:00 ` cvs-commit at gcc dot gnu.org
  2021-03-19 13:21 ` jakub at gcc dot gnu.org
  2021-03-29 11:19 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-29 16:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:506fcfdb12562e829448e2b2eff475c65986e26b

commit r10-9312-g506fcfdb12562e829448e2b2eff475c65986e26b
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 13 13:27:06 2021 -0500

    c++: Avoid redundant copy in {} init [PR98642]

    Here, initializing from { } implies a call to the default constructor for
    base.  We were then seeing that we're initializing a base subobject, so we
    tried to copy the result of that call.  This is clearly wrong; we should
    initialize the base directly from its default constructor.

    gcc/cp/ChangeLog:

            PR c++/98642
            * typeck2.c (split_nonconstant_init_1): Don't copy a list-init
            constructor call.

    gcc/testsuite/ChangeLog:

            PR c++/98642
            * g++.dg/cpp1z/elide5.C: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-01-29 16:00 ` cvs-commit at gcc dot gnu.org
@ 2021-03-19 13:21 ` jakub at gcc dot gnu.org
  2021-03-29 11:19 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-19 13:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So is this now fixed even for 10.3?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug c++/98642] [10 Regression] wrong "use of deleted function" error
  2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2021-03-19 13:21 ` jakub at gcc dot gnu.org
@ 2021-03-29 11:19 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-29 11:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98642

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reported testcase is now accepted.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-03-29 11:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 19:51 [Bug c++/98642] New: wrong "use of deleted function" error mpolacek at gcc dot gnu.org
2021-01-12 19:52 ` [Bug c++/98642] [10/11 Regression] " mpolacek at gcc dot gnu.org
2021-01-12 19:56 ` mpolacek at gcc dot gnu.org
2021-01-12 20:55 ` jason at gcc dot gnu.org
2021-01-15 18:57 ` cvs-commit at gcc dot gnu.org
2021-01-15 19:12 ` jason at gcc dot gnu.org
2021-01-27  9:34 ` [Bug c++/98642] [10 " rguenth at gcc dot gnu.org
2021-01-27  9:36 ` rguenth at gcc dot gnu.org
2021-01-29 16:00 ` cvs-commit at gcc dot gnu.org
2021-03-19 13:21 ` jakub at gcc dot gnu.org
2021-03-29 11:19 ` rguenth 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).