[Bug c++/61381] New: constexpr non captured by template lambda

vincenzo.innocente at cern dot ch gcc-bugzilla@gcc.gnu.org
Sun Jun 1 14:54:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61381

            Bug ID: 61381
           Summary: constexpr non captured by template lambda
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch

cat ceLambda.cc 
struct Bar {  constexpr Bar(float i):f(i){}; float f;};
float foo1(float x) {
   constexpr Bar z{0};

   auto f = [=](auto a, auto b) -> Bar { return z;};

   return f(x,x).f;

}

float foo2(float x) {
   const Bar z{0};

   auto f = [=](auto a, auto b) -> Bar { return z;};

   return f(x,x).f;

}

float foo3(float x) {
   constexpr Bar z{0};

   auto f = [=](float a, float b) -> Bar { return z;};

   return f(x,x).f;

}

b-d-128-141-131-42:ctest innocent$ c++ -O2 -std=c++1y -S ceLambda.cc 
ceLambda.cc: In instantiation of ‘foo1(float)::<lambda(auto:1, auto:2)> [with
auto:1 = float; auto:2 = float]’:
ceLambda.cc:7:16:   required from here
ceLambda.cc:5:49: error: ‘z’ was not declared in this scope
    auto f = [=](auto a, auto b) -> Bar { return z;};
                                                 ^


More information about the Gcc-bugs mailing list