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

            Bug ID: 102191
           Summary: Can't return prvalue with potentially-throwing
                    destructor during constant evaluation
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          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: ---

See https://godbolt.org/z/8evPWv7cb.
```C++
struct X {
  struct A {
    constexpr ~A() noexcept(false) { }
  };

  constexpr A operator()(auto...) { return {}; }
};

void f() { []() consteval { X{}(); }(); }
```
```
<source>: In function 'void f()':
<source>:9:37:   in 'constexpr' expansion of '<lambda closure
object>f()::<lambda()>().f()::<lambda()>()'
<source>:9:37:   in 'constexpr' expansion of 'X::operator()(auto:1 ...) [with
auto:1 = {}]()'
<source>:9:37: error: modification of '<anonymous>' is not a constant
expression
    9 | void f() { []() consteval { X{}(); }(); }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~^~
Compiler returned: 1
```

Reply via email to