public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55149] New: capturing VLA in lambda (error in 4.7.2 ICE in 4.8
@ 2012-10-31 13:02 vincenzo.innocente at cern dot ch
  2012-10-31 21:57 ` [Bug c++/55149] " daniel.kruegler at googlemail dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-10-31 13:02 UTC (permalink / raw)
  To: gcc-bugs


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-07 23:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-31 13:02 [Bug c++/55149] New: capturing VLA in lambda (error in 4.7.2 ICE in 4.8 vincenzo.innocente at cern dot ch
2012-10-31 21:57 ` [Bug c++/55149] " daniel.kruegler at googlemail dot com
2012-11-07  9:40 ` [Bug c++/55149] [4.8 Regression] capturing VLA in lambda jakub at gcc dot gnu.org
2012-11-07 15:01 ` [Bug c++/55149] " paolo.carlini at oracle dot com
2012-11-30  9:31 ` paolo.carlini at oracle dot com
2012-11-30  9:33 ` paolo.carlini at oracle dot com
2013-04-17 14:19 ` paolo.carlini at oracle dot com
2013-05-10  0:56 ` paolo.carlini at oracle dot com
2013-05-10 14:31 ` jason at gcc dot gnu.org
2013-05-10 14:59 ` paolo.carlini at oracle dot com
2013-06-06 21:16 ` david.abdurachmanov at gmail dot com
2013-06-07 13:34 ` jason at gcc dot gnu.org
2013-06-07 17:01 ` david.abdurachmanov at gmail dot com
2013-06-07 23:29 ` 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).