From deb9c51ca71d3cb507dd91ab8bfd8c1021effd9f Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Mon, 29 Jun 2020 00:36:38 +0300 Subject: [PATCH] PR libstdc++/95915 PR libstdc++/95915 * include/std/variant (_Uninitialized): Adjust the condition and the comment. * testsuite/20_util/variant/95915.cc: New. * testsuite/20_util/variant/compile.cc: Add new test. (cherry picked from commit 24b54628cfa95194a8de4071c28cb56e6e81c08e) --- libstdc++-v3/include/std/variant | 12 ++----- .../testsuite/20_util/variant/95915.cc | 35 +++++++++++++++++++ .../testsuite/20_util/variant/compile.cc | 7 ++++ 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/variant/95915.cc diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 258a5fb18bdc..010138df9f29 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -202,15 +202,9 @@ namespace __variant std::forward<_Variants>(__variants)...); } - // _Uninitialized is guaranteed to be a literal type, even if T is not. - // We have to do this, because [basic.types]p10.5.3 (n4606) is not implemented - // yet. When it's implemented, _Uninitialized can be changed to the alias - // to T, therefore equivalent to being removed entirely. - // - // Another reason we may not want to remove _Uninitialzied may be that, we - // want _Uninitialized to be trivially destructible, no matter whether T - // is; but we will see. - template> + // _Uninitialized is guaranteed to be a trivially destructible type, + // even if T is not. + template> struct _Uninitialized; template diff --git a/libstdc++-v3/testsuite/20_util/variant/95915.cc b/libstdc++-v3/testsuite/20_util/variant/95915.cc new file mode 100644 index 000000000000..411ff2d36ae8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/variant/95915.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +using namespace std; + +struct virtual_default_dtor { + virtual ~virtual_default_dtor() = default; +}; + +void default_ctor() +{ + { + variant a; + } +} + diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc b/libstdc++-v3/testsuite/20_util/variant/compile.cc index a53071c88677..4f2ed68426ab 100644 --- a/libstdc++-v3/testsuite/20_util/variant/compile.cc +++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc @@ -84,6 +84,10 @@ struct nonliteral bool operator>(const nonliteral&) const; }; +struct virtual_default_dtor { + virtual ~virtual_default_dtor() = default; +}; + void default_ctor() { static_assert(is_default_constructible_v>); @@ -95,6 +99,9 @@ void default_ctor() static_assert(noexcept(variant())); static_assert(!noexcept(variant())); static_assert(noexcept(variant())); + { + variant a; + } } void copy_ctor() -- 2.47.2