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

            Bug ID: 95915
           Summary: std::variant doesn't like types with a defaulted
                    virtual destructor
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
  Target Milestone: ---

>From Patrice Roy:

The following code compiled in C++17 but seems broken in C++20, at least
according the Clang and gcc:

#include <variant>
struct X {
   virtual ~X() = default;
};
int main() {
   std::variant<X> v;
}

This is because variant's storage uses an _Uninitialized type that hacks
around a compiler bug, where the type X above wasn't literal. Now that it
is, the hack breaks. Since variant's other base-layers handle triviality
of special member functions properly, this hack can now be removed.

Reply via email to