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

            Bug ID: 102284
           Summary: Can access object outside of its lifetime during
                    constant evaluation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

This is prohibited at https://eel.is/c++draft/basic.life#7.1.
See https://godbolt.org/z/exKnnT935.
```C++
#include <memory>
struct X { int x; };
int main() {
  []() consteval {
    {
      X x{};
      x.~X();
      ++x.x;
      std::construct_at(&x);
    }
    {
      union { X x{}; };
      x.~X();
      ++x.x;
    }
  }();
}
```

Reply via email to