================
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+struct Noisy {
+  int x;
+  consteval Noisy(int x) : x(x) {}
+  ~Noisy() {}
+};
+
+struct Function {
+  template <typename F> Function(F) {}
+};
+
+struct Options {
+  int x;
+  Function function{ // expected-note {{declared here}}
+      // expected-error@+2 {{call to consteval function}}
+      // expected-note@+1 {{implicit use of 'this' pointer is only allowed 
within the evaluation of a call to a 'constexpr' member function}}
----------------
efriedma-quic wrote:

This error message doesn't look right.  The implicit use of "this" should be 
allowed here; if you replace the call to foo() with a constant, we should 
accept.  `this` refers to the object being constructed.

I guess that isn't specific to lambdas, though; I'm okay with opening a 
followup bug.  Compare the following with clang vs. gcc:

```
struct Noisy {
  int x;
  consteval Noisy(int x) : x(x) {}
  constexpr ~Noisy() {}
};

struct Function {
  template <typename F> constexpr Function(F) {}
};

struct Options {
  int x;
  Function function{Noisy{x}};
};

int foo();
Options kOptions{5};
```

https://github.com/llvm/llvm-project/pull/196597
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to