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

            Bug ID: 102163
           Summary: std::variant rejects valid constant expression
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

#include <variant>

struct O {
  O() = default;
  O(O&&) = default;
  O(const O&) = default;
  O& operator=(const O&) = default;
  O& operator=(O&&) = default;
  ~O() = default;

  constexpr O(int x) {}
};

constexpr std::variant<float, O> v{42};

https://godbolt.org/z/PdEx4z7rf

GCC-trunk rejected it under -std=c++20, it seems to be a language feature bug.

Reply via email to