hubert.reinterpretcast added a comment.

Lambda capture semantics mean that extensions or inconsistencies in constexpr 
evaluation result in binary-compatibility issues.

  struct NonLit {
    NonLit();
  };
  template <typename T>
  constexpr int foo() {
    return 42;
    T t;
  }
  extern int g(void *);
  inline int f(void *p) {
    const int x = foo<NonLit>();
    auto ff = [=] { return x; };
    using ty = decltype(ff);
    if (p) {
      return (*(ty *)p)();
    }
    return g(&ff);
  }
  int g(void *p) { if (!p) return 0; return f(p); }

Notice that GCC reads from the closure object in C++20: 
https://godbolt.org/z/vYs63h8vb.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111400/new/

https://reviews.llvm.org/D111400

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to