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

Antony Polukhin <antoshkka at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-reduction,            |accepts-invalid
                   |rejects-valid               |

--- Comment #2 from Antony Polukhin <antoshkka at gmail dot com> ---
Reduced version. Note that Clang reduces to compile it with any -O, while GCC
is fine with it on -O0 https://godbolt.org/z/yTM0a4 :


template <typename _Tp>
struct unique_ptr {
    _Tp* pointer_{};

    explicit unique_ptr(_Tp* __p) noexcept
        : pointer_(__p) {}

    ~unique_ptr() noexcept {
        delete pointer_;
    }

    unique_ptr(const unique_ptr&) = delete;
    unique_ptr& operator=(const unique_ptr&) = delete;
};

namespace my {
    template<typename _Tp, typename... _Args>
    unique_ptr<_Tp> make_unique(_Args&&... __args)
    { return unique_ptr<_Tp>(new _Tp(static_cast<_Args&&>(__args)...)); }

  template<class Target, typename _Tp>
    constexpr Target move(_Tp&& __t) noexcept
    { return static_cast<Target>(__t); }
}

struct widget;

template <class T, bool IsDefaultconstr>
struct my_variant_impl  {
    T value;
    my_variant_impl() = default;
    my_variant_impl(T&& val) : value(val) {};
};

template <class T>
struct my_variant
    : my_variant_impl<T, __is_constructible(T)> 
{};

using variant_t = my_variant<widget>;

struct my_func {
    my_func(variant_t&& arg) {
        my::make_unique<variant_t>(my::move<variant_t&&>(arg));
    }
};

struct widget {};
my_func f({});

Reply via email to