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++/61381] New: constexpr non captured by template lambda


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;};
                                                 ^

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