public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56973] New: crash when capturing variables in nested lambdas
@ 2013-04-15 18:35 dirkmoermans at gmail dot com
2013-04-21 11:41 ` [Bug c++/56973] " dirkmoermans at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dirkmoermans at gmail dot com @ 2013-04-15 18:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56973
Bug #: 56973
Summary: crash when capturing variables in nested lambdas
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dirkmoermans@gmail.com
The valid C++11 program below segfaults on my machine:
=====
#include <cassert>
#include <cstring>
#include <iterator>
void test(const char* s)
{
constexpr /*static*/ struct {const char* s;} ar[]={
{"e4"},
{"e5"},
{"Nf3"},
{"Nc6"},
{"Bb5"},
{"a6"}
};
auto it=std::begin(ar);
auto compare=[&it](const char* s)
{
assert(std::strcmp(it->s,s)==0);
};
auto test=[&](const char* s)
{
it=std::begin(ar);
compare(s);
};
test(s);
}
int main(int argc, const char* argv[])
{
test(argv[1]);
test(argv[2]);
test(argv[3]);
return 0;
}
=====
I compile with: $ g++ -g -O --std=c++11 bug.cc.
I run as: $ ./a.out e4 e4 e4
My machine is a 64 bit linux intel core duo 2 (T4200).
If I make "ar" static the program passes, so I assume that ar is overwritten
prematurely on the stack.
The error only occurs from optimization-levels "-O" onwards.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/56973] crash when capturing variables in nested lambdas
2013-04-15 18:35 [Bug c++/56973] New: crash when capturing variables in nested lambdas dirkmoermans at gmail dot com
@ 2013-04-21 11:41 ` dirkmoermans at gmail dot com
2013-04-21 11:43 ` dirkmoermans at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: dirkmoermans at gmail dot com @ 2013-04-21 11:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56973
--- Comment #1 from Dirk Moermans <dirkmoermans at gmail dot com> 2013-04-21 11:41:33 UTC ---
Created attachment 29909
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29909
preprocessed file
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/56973] crash when capturing variables in nested lambdas
2013-04-15 18:35 [Bug c++/56973] New: crash when capturing variables in nested lambdas dirkmoermans at gmail dot com
2013-04-21 11:41 ` [Bug c++/56973] " dirkmoermans at gmail dot com
@ 2013-04-21 11:43 ` dirkmoermans at gmail dot com
2013-04-24 9:38 ` paolo.carlini at oracle dot com
2013-07-10 23:30 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: dirkmoermans at gmail dot com @ 2013-04-21 11:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56973
--- Comment #2 from Dirk Moermans <dirkmoermans at gmail dot com> 2013-04-21 11:43:02 UTC ---
the output of gcc -v
Using built-in specs.
COLLECT_GCC=g++-4.8.0
COLLECT_LTO_WRAPPER=/home/dirk/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/home/dirk/local --program-suffix=-4.8.0
--enable-languages=c,c++
Thread model: posix
gcc version 4.8.0 (GCC)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/56973] crash when capturing variables in nested lambdas
2013-04-15 18:35 [Bug c++/56973] New: crash when capturing variables in nested lambdas dirkmoermans at gmail dot com
2013-04-21 11:41 ` [Bug c++/56973] " dirkmoermans at gmail dot com
2013-04-21 11:43 ` dirkmoermans at gmail dot com
@ 2013-04-24 9:38 ` paolo.carlini at oracle dot com
2013-07-10 23:30 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-04-24 9:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56973
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-04-24
Blocks| |54367
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/56973] crash when capturing variables in nested lambdas
2013-04-15 18:35 [Bug c++/56973] New: crash when capturing variables in nested lambdas dirkmoermans at gmail dot com
` (2 preceding siblings ...)
2013-04-24 9:38 ` paolo.carlini at oracle dot com
@ 2013-07-10 23:30 ` paolo.carlini at oracle dot com
3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-10 23:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56973
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Priority|P3 |P2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-10 23:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 18:35 [Bug c++/56973] New: crash when capturing variables in nested lambdas dirkmoermans at gmail dot com
2013-04-21 11:41 ` [Bug c++/56973] " dirkmoermans at gmail dot com
2013-04-21 11:43 ` dirkmoermans at gmail dot com
2013-04-24 9:38 ` paolo.carlini at oracle dot com
2013-07-10 23:30 ` paolo.carlini at oracle dot com
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).