[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

Tyker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 01:16:51 PDT 2019


Tyker added a comment.

The now that constexpr destructors are legal. The code in this patch need to be adapted, I have question about the following code.

  struct A {
    constexpr ~A() {}
  };
  
  consteval A f() {
      return A{};
  }
  
  void test() {
      A a;
      a = f(); // <-- here
  }

At the point i marked.
The invocation of f causes an immediate invocation (http://eel.is/c++draft/expr.const#12).
Immediate invocation are full expression (http://eel.is/c++draft/intro.execution#5).
Full expression resolve all there side-effects before evaluating the next full expression (http://eel.is/c++draft/intro.execution#9).
The return value of f() is created inside the immediate invocation.
So the destructor of the value returned by f() should be destroyed within the immediate evaluation.
But that value is needed for the assignment operator.
This seem contradictory. What have i misunderstood ? What should happen here ?


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

https://reviews.llvm.org/D63960





More information about the cfe-commits mailing list