public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64429] New: Double free when returning std::string from trivial lambda
@ 2014-12-28 18:17 charlie at charliedyson dot net
2014-12-29 0:02 ` [Bug c++/64429] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: charlie at charliedyson dot net @ 2014-12-28 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64429
Bug ID: 64429
Summary: Double free when returning std::string from trivial
lambda
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: charlie at charliedyson dot net
The following causes a double free on gcc 4.8.2 as shipped with Ubuntu, and
various other versions I tested on Wandbox.
Interestingly enough, explicitly copying the string inside the lambda seems to
fix it.
Code:
#include <string>
using F = std::string(*)(std::string);
std::string call_fn_pointer(F f, std::string s)
{
return f(s);
}
std::string f(std::string s) { return s; }
int main()
{
// fine
call_fn_pointer(f, "foo");
// fine
call_fn_pointer([] (std::string s) { return std::string(s); }, "foo");
// double free
call_fn_pointer([] (std::string s) { return s; }, "foo");
}
Invocation:
$ g++ -std=c++1y foo.cpp -o foo -Wall
$ ./foo
*** Error in `./foo': double free or corruption (fasttop): 0x08372008 ***
Aborted
Apologies in advance if I've found another duplicate! Could this relate to
64329?
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/64429] Double free when returning std::string from trivial lambda
2014-12-28 18:17 [Bug c++/64429] New: Double free when returning std::string from trivial lambda charlie at charliedyson dot net
@ 2014-12-29 0:02 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-29 0:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64429
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
More likely to be PR 62052
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-29 0:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-28 18:17 [Bug c++/64429] New: Double free when returning std::string from trivial lambda charlie at charliedyson dot net
2014-12-29 0:02 ` [Bug c++/64429] " 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).