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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
First attempt so simplify (and to get rid of some library dependencies):

//---------------------------------
#include <functional>

struct Impl_base
{
  virtual ~Impl_base(){}
  virtual void run() = 0;
};

template<typename Callable>
  struct Impl : public Impl_base
  {
    Callable func;
    Impl(Callable f) : func(f) { }
    void run() { func(); }
  };

template<typename Callable>
  void
  make_routine(Callable&& f)
  {
    new Impl<Callable>(static_cast<Callable&&>(f));
  }

template<typename Callable>
void make(Callable&& f)
  {
    make_routine(std::__bind_simple(f));
  }

extern void use(float);

int main(){
    int y = 2;
    float fa[2][y]; // compiles fine if y were 2 hard-coded instead
    fa[0][0]=0.8;
    fa[0][1]=1.8;
    auto fx=[&](){
        for(int c=0; c<2; c++){ // compiles fine if c<2 were c<1 instead
            use(fa[0][c]);
        }
    };
    make(fx); //error (1*)
}
//---------------------------------

causes the same error (using gcc 4.9.0 20130519 (experimental)):

"main.cpp||In function 'int main()':|
main.cpp|34|warning: ISO C++ forbids variable length array 'fa' [-Wvla]|
main.cpp||In member function 'void Impl<Callable>::run() [with Callable =
std::_Bind_simple<main()::<lambda()>()>]':|
main.cpp|39|warning: '<anonymous>' is used uninitialized in this function
[-Wuninitialized]|
|34|note: '<anonymous>' was declared here|
main.cpp|39|internal compiler error: in expand_expr_real_1, at expr.c:9361|
"

Reply via email to