This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/56304] New: [C++1] ICE in get_expr_operands, at tree-ssa-operands.c for template class, using lambda with closure on member variable, also called by the constructor


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56304

             Bug #: 56304
           Summary: [C++1] ICE in get_expr_operands, at
                    tree-ssa-operands.c for template class, using lambda
                    with closure on member variable, also called by the
                    constructor
    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


This bug is similar to 56303, but gives a slightly different error message: in
get_expr_operands, at tree-ssa-operands.c. The differences from 56303 case are: 

1) a function f() is called from the constructor
2) in f(), a reference to a member variable is created and passed to a lambda

So, the program is 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 "get_expr_operands, at tree-ssa-operands.c".

I attach the .ii file generated by the compiler (4.7.2 on Windows 7 64bit). 

The program is :

////////////////////////////////////


#include <algorithm>
#include <vector>
#include <set>

using namespace std;

template<class elements_it>
class my_iterator
{
public:
    my_iterator(
        elements_it elements_begin,
        elements_it elements_end) :
        elements_begin_(elements_begin),
        elements_end_(elements_end),
        elements_used(distance(elements_begin, elements_end))
    {
        f();
    }

    void f()
    {
        size_t &ii = i;

        for_each(elements_begin_, elements_end_, [&](typename
elements_it::value_type) 
        {
            if(elements_used[ii]) return;

            g();
        });
    }

    void g()
    {
    }

private:
    elements_it elements_begin_;
    elements_it elements_end_;
    size_t i;
    vector<int> elements_used;
};

int main(int, char **)
{
    set<int> elements1 = { 1, 2, 3 };

    my_iterator<set<int>::iterator> i1(begin(elements1), end(elements1));
}

////////////////////////////////////

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:50:1: internal compiler error: in get_expr_operands, at
tree-ssa-operands.c:1035
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]