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

            Bug ID: 115846
           Summary: std::optional<std::unique_ptr<int>> is constant
                    expression even in C++20 mode
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

#include <memory>
#include <optional>

// static_assert([] {
//   std::unique_ptr<int> p; // non-constant condition for static assertion
//   return true;
// }());

static_assert([] {
  std::optional<std::unique_ptr<int>> opt;
  return true;
}());

GCC rejects the first but accepts the last, which seems wrong since
unique_ptr's destructor is not constexpr in C++20.

https://godbolt.org/z/38bToE8oE

Reply via email to