[Bug c++/83130] New: Compilation error related to 'using', template instantiations and default constructors

nadult at fastmail dot fm gcc-bugzilla@gcc.gnu.org
Thu Nov 23 13:40:00 GMT 2017


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

            Bug ID: 83130
           Summary: Compilation error related to 'using', template
                    instantiations and default constructors
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nadult at fastmail dot fm
  Target Milestone: ---

The following code fails to compile on new GCC (7.1, 7.2, 8.0). It compiles
without any problems on Clang. Compiled with: -std=c++1z

#include <utility>

template <class T> struct ValueBase {
    ValueBase() {}
    ValueBase(const ValueBase &src) {}
    ValueBase(ValueBase &&src) {}
    void operator=(ValueBase &&src) {}
    void operator=(const ValueBase &src) {}
};

template <class T> struct Value : public ValueBase<T> {
    Value(void *) {}
    using ValueBase<T>::ValueBase;
    using ValueBase<T>::operator=;
};

struct MyObj {
    MyObj();
    MyObj(const MyObj &);

    struct Impl {
        // Uncomment these lines to make the bug go away:
        //Impl() = default;
        //Impl(const Impl &) = default;

        Value<double> value;
    };

    std::pair<Impl, Impl> pair;
};

MyObj::MyObj(const MyObj &) = default;

void someFunc() {
    std::pair<MyObj::Impl, MyObj::Impl> impl;
    // Comment this line to make the bug go away
    impl.first.value = nullptr;
}


More information about the Gcc-bugs mailing list