This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/56303] New: [C++11] ICE in lambda with closure on member variable of a template class
- From: "crillion at tiscali dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 Feb 2013 10:17:21 +0000
- Subject: [Bug c++/56303] New: [C++11] ICE in lambda with closure on member variable of a template class
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56303
Bug #: 56303
Summary: [C++11] ICE in lambda with closure on member variable
of a template class
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: crillion@tiscali.it
Created attachment 29432
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29432
the ii file generated by the compiler
Hi,
I get an internal compiler error with a C++11 program on GCC 4.7.2,
targeting MinGW on Windows 7 64 bit. I've also checked that the same error is
generated on GCC 4.7.1 on a linux virtual machine (opensuse 12.2 64bit on
VirtualBox, hosted by my Windows 7 64 bit operating system).
As requested on instructions, I have used the -Wall -Wextra
-fno-strict-aliasing -fwrapv options to better detect errors in code but that
didn't change the result. I also used -pedantic, idem. I used -save-temps to
save the ii file that I attach to this post.
The error is "Segmentation Fault".
I've seen I get it using a closure, also with variants in the use of []
operator: [&], [this], [=] as indicated in the comment in the code.
When I write [] I get "this not captured" error instead (seems no compiler
error).
I attach the .ii file generated by the compiler (4.7.2 on Windows 7 64bit).
The program is :
////////////////////////////////////
#include <set>
#include <vector>
using namespace std;
template<class elements_it>
class my_iterator
{
public:
my_iterator(elements_it begin, elements_it end) :
begin_(begin), end_(end), i(0) {}
void f()
{
for_each(begin_, end_, [=](typename elements_it::value_type)
{
// segmentation fault with [&], [this], [=]
// "this" not captured with []
if(v[i]) return;
});
}
private:
elements_it begin_;
elements_it end_;
size_t i;
vector<int> v;
};
int main(int argc, char* argv[])
{
set<int> elements = { 1, 2, 3 };
my_iterator<set<int>::iterator> it(begin(elements), end(elements));
}
////////////////////
I get the following compiler error:
>g++ -pedantic -Wall -Wextra -fno-strict-aliasing -fwrapv -save-temps --st
d=c++11 test_enumeration1.cpp -o test_enumeration1_gpp.exe
test_enumeration1.cpp: In lambda function:
test_enumeration1.cpp:21:10: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.