public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65354] New: Converting lambda to pointer results in double destruction
@ 2015-03-08 19:42 charlie at charliedyson dot net
  2015-03-08 22:30 ` [Bug c++/65354] " daniel.kruegler at googlemail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: charlie at charliedyson dot net @ 2015-03-08 19:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65354
           Summary: Converting lambda to pointer results in double
                    destruction
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: charlie at charliedyson dot net

In the following, the unique_ptr is deleted twice if the lambda is converted to
a function pointer (#if 1) but runs without error if left as a lambda.

Compiled with g++-4.8 test.cpp -o test -std=c++1y on Linux Mint 17 x64.

I get the following output in the function pointer case:
Bye
Bye
*** Error in `./test': double free or corruption (fasttop): 0x0000000001e5c010
***
Aborted

Here's the code:

#include <memory>
#include <iostream>

struct X
{
    ~X () { std::cout << "Bye" << std::endl; }
};

struct Y
{
    explicit Y (std::unique_ptr<X> x)
    : m_x (std::move (x))
    { }

    std::unique_ptr<X> m_x;
};

int main ()
{
    using F = Y (*) (std::unique_ptr<X>);
    auto p = std::unique_ptr<X> {new X};

#if 1
    F f =
#else
    auto f =
#endif
    [] (std::unique_ptr<X> x)
    {
        return Y (std::move (x));
    };
    f (std::move (p));
}


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

* [Bug c++/65354] Converting lambda to pointer results in double destruction
  2015-03-08 19:42 [Bug c++/65354] New: Converting lambda to pointer results in double destruction charlie at charliedyson dot net
@ 2015-03-08 22:30 ` daniel.kruegler at googlemail dot com
  2015-03-09  8:05 ` charlie at charliedyson dot net
  2015-03-09 10:13 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-03-08 22:30 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The problem also occurs in all release versions of 4.9.x and in the current
HEAD 5.0.0 20150306 (experimental).
>From gcc-bugs-return-479715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Mar 08 22:59:30 2015
Return-Path: <gcc-bugs-return-479715-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 102817 invoked by alias); 8 Mar 2015 22:59:30 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 102753 invoked by uid 55); 8 Mar 2015 22:59:26 -0000
From: "danglin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/62251] FAIL: gfortran.dg/quad_2.f90 execution test
Date: Sun, 08 Mar 2015 22:59:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: danglin at gcc dot gnu.org
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-62251-4-U8RtsjincO@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62251-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62251-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg00859.txt.bz2
Content-length: 424

https://gcc.gnu.org/bugzilla/show_bug.cgi?idb251

--- Comment #8 from John David Anglin <danglin at gcc dot gnu.org> ---
Author: danglin
Date: Sun Mar  8 22:58:52 2015
New Revision: 221267

URL: https://gcc.gnu.org/viewcvs?rev"1267&root=gcc&view=rev
Log:
    PR target/62251
    * gfortran.dg/quad_2.f90: xfail hppa*-*-hpux*.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/quad_2.f90


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

* [Bug c++/65354] Converting lambda to pointer results in double destruction
  2015-03-08 19:42 [Bug c++/65354] New: Converting lambda to pointer results in double destruction charlie at charliedyson dot net
  2015-03-08 22:30 ` [Bug c++/65354] " daniel.kruegler at googlemail dot com
@ 2015-03-09  8:05 ` charlie at charliedyson dot net
  2015-03-09 10:13 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: charlie at charliedyson dot net @ 2015-03-09  8:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Charlie <charlie at charliedyson dot net> ---
Here's a more succinct example (using the "+" trick to convert to a function
pointer):

#include <iostream>

int main ()
{
    auto f = +[] (std::string s)
    {
      return std::string (std::move (s));
    };
    std::string s ("hello");
    f (std::move (s));
}


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

* [Bug c++/65354] Converting lambda to pointer results in double destruction
  2015-03-08 19:42 [Bug c++/65354] New: Converting lambda to pointer results in double destruction charlie at charliedyson dot net
  2015-03-08 22:30 ` [Bug c++/65354] " daniel.kruegler at googlemail dot com
  2015-03-09  8:05 ` charlie at charliedyson dot net
@ 2015-03-09 10:13 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-09 10:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is PR 62052

*** This bug has been marked as a duplicate of bug 62052 ***


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

end of thread, other threads:[~2015-03-09 10:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-08 19:42 [Bug c++/65354] New: Converting lambda to pointer results in double destruction charlie at charliedyson dot net
2015-03-08 22:30 ` [Bug c++/65354] " daniel.kruegler at googlemail dot com
2015-03-09  8:05 ` charlie at charliedyson dot net
2015-03-09 10:13 ` 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).