This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/55149] New: capturing VLA in lambda (error in 4.7.2 ICE in 4.8
- From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Oct 2012 13:02:37 +0000
- Subject: [Bug c++/55149] New: capturing VLA in lambda (error in 4.7.2 ICE in 4.8
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55149
Bug #: 55149
Summary: capturing VLA in lambda (error in 4.7.2 ICE in 4.8
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vincenzo.innocente@cern.ch
given that assigning a VLA to a pointer seems to be legal, I was expecting to
be able to capture a VLA in a lambda
in this code
cat pointerVLA.cc
#include<algorithm>
float c(int j,int k);
void bar(int * index, int * ref, int N, int CN ) {
float r[N*CN];
decltype(N) ii=0;
for (decltype(N) ir=0; ir!=N; ++ir)
for(decltype(N) cl=0;cl!=CN;++cl)
r[ii++]=c(cl,ref[ir]);
#ifdef VLA
std::sort(index,index+N,[r,CN](int i, int j) { return
std::lexicographical_compare(r+i*CN,r+i*CN+CN,r+j*CN,r+j*CN+CN);});
#else
const float * rr = r;
std::sort(index,index+N,[rr,CN](int i, int j) { return
std::lexicographical_compare(rr+i*CN,rr+i*CN+CN,rr+j*CN,rr+j*CN+CN);});
#endif
}
compiles fine with the assignment rr = r;
instead
gcc version 4.7.2 20120813 (prerelease) (GCC)
c++ -O2 -std=c++11 -c pointerVLA.cc -DVLA
pointerVLA.cc: In function 'void bar(int*, int*, int, int)':
pointerVLA.cc:10:121: error: no matching function for call to 'sort(int*&,
int*, bar(int*, int*, int, int)::<lambda(int, int)>)'
pointerVLA.cc:10:121: note: candidates are:
In file included from
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/algorithm:63:0,
from pointerVLA.cc:1:
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/bits/stl_algo.h:5463:5:
note: template<class _RAIter> void std::sort(_RAIter, _RAIter)
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/bits/stl_algo.h:5463:5:
note: template argument deduction/substitution failed:
pointerVLA.cc:10:121: note: candidate expects 2 arguments, 3 provided
In file included from
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/algorithm:63:0,
from pointerVLA.cc:1:
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/bits/stl_algo.h:5499:5:
note: template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter,
_Compare)
/build1/sw/osx108_amd64_gcc470/external/gcc/4.7.0/bin/../lib/gcc/x86_64-apple-darwin12.0.0/4.7.2/../../../../include/c++/4.7.2/bits/stl_algo.h:5499:5:
note: template argument deduction/substitution failed:
pointerVLA.cc:10:121: note: variable-sized array type 'bar(int*, int*, int,
int)::<lambda(int, int)>' is not a valid template argument
gcc version 4.8.0 20121028 (experimental) [trunk revision 192889] (GCC)
c++ -O2 -std=c++11 -c pointerVLA.cc -DVLA
pointerVLA.cc: In function âvoid bar(int*, int*, int, int)â:
pointerVLA.cc:10:31: internal compiler error: tree check: expected integer_cst,
have mult_expr in walk_subobject_offsets, at cp/class.c:3516
std::sort(index,index+N,[r,CN](int i, int j) { return
std::lexicographical_compare(r+i*CN,r+i*CN+CN,r+j*CN,r+j*CN+CN);});
^
pointerVLA.cc:10:31: internal compiler error: Abort trap: 6
c++: internal compiler error: Abort trap: 6 (program cc1plus)
Abort trap: 6