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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Here's a silly example which works with GCC 8 but fails with current trunk:

#include <variant>

struct S {
  S(int) : a() { }
  char a[8192 * 1024];
};

int main() {
  auto& v = *new std::variant<int, S>;
  v.emplace<S>(1);
  S &s = std::get<1>(v);
  return s.a[0];
}

This blows my shell's default 8kb stack limit, because of the temporary that
gets created on the stack.

We could revert to having never-valueless depend on (is_scalar_v<_Types>&&...)
or keep depending on is_trivially_copyable but also check that all the
alternative types are smaller than some limit like 512 bytes.

Reply via email to