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++/71116] New: Lambdas should not be literal types


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

            Bug ID: 71116
           Summary: Lambdas should not be literal types
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com
  Target Milestone: ---

#include <type_traits>

template <class Fn>
void oops(Fn) {
  static_assert(!std::is_literal_type<Fn>::value, "oops");
}

int main() {
  oops([]{});
}

Yields:

test.cpp: In instantiation of âvoid oops(Fn) [with Fn = main()::<lambda()>]â:
test.cpp:9:12:   required from here
test.cpp:5:3: error: static assertion failed: oops
   static_assert(!std::is_literal_type<Fn>::value, "oops");
   ^~~~~~~~~~~~~


([expr.prim.lambda]/p3) "The type of the lambda-expression (which is also the
type of the closure object) is a unique, unnamed non-union class type â called
the closure type â whose properties are described below. This class type is
neither an aggregate (8.5.1) nor a literal type (3.9)."

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