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

--- Comment #12 from Louis Dionne <ldionne.2 at gmail dot com> ---
The following code still fails to compile on GCC trunk:

    template <typename Xn>
    struct tuple {
        Xn storage_;

        constexpr tuple(Xn const& xn)
            : storage_(xn)
        { }

        template <typename ...dummy>
        constexpr tuple(tuple const& other)
            : storage_(other.storage_)
        { }

        template <typename ...dummy>
        constexpr tuple(tuple& other)
            : tuple(const_cast<tuple const&>(other))
        { }
    };

    template <typename T>
    struct wrapper { T value; };

    template <typename T>
    constexpr wrapper<T> wrap(T t) { return {t}; }

    constexpr wrapper<tuple<int>> t = wrap(tuple<int>{2});
    static_assert(t.value.storage_ == 2, "");


The error is

    prog.cc:27:5: error: non-constant condition for static assertion
         static_assert(t.value.storage_ == 2, "");
         ^~~~~~~~~~~~~
    prog.cc:27:5: error: accessing uninitialized member 'tuple<int>::storage_'


Note that if the `static_assert` is changed to a runtime assertion, and if `t`
is not made `constexpr`, this code will trigger a runtime error. I'm pretty
sure
the above is triggered by the current bug.

Reply via email to