G++ fails when compiling the following program in
g++0x mode. It displays "spooky action at a distance"
when instantiating the member_ptr template, but I
expect the converting assignment operator from weak_ptr
to be selected instead.

-------------------------8<-----------------------


#include <type_traits>

    class A {

    };

    class B : public A {

    };

    class C {

    };


    namespace gc {

        template <typename T> class member_ptr;
    }


    template <typename T> class weak_ptr {

    public:

        weak_ptr() {}

        template <typename X> weak_ptr(const weak_ptr<X>& v) {}

        weak_ptr(const weak_ptr&) = default;

        weak_ptr(const gc::member_ptr<T>& v);

        ~weak_ptr() = default;

        // ------------------

        weak_ptr& operator =(const weak_ptr&) = default;

        template <typename X> weak_ptr& operator =(const weak_ptr<X>& v) {
return *this; }
    };

    namespace gc {

        template <typename T> class member_ptr {

            static_assert(std::is_base_of<C, T>::value,
              "spooky action at a distance");
        };
    }



int main(int argc, char *argv[]) {

    weak_ptr<A> ap1;
    weak_ptr<B> bp1;

    ap1 = bp1;

    return 0;
}


-------------------------8<-----------------------


-- 
           Summary: static_assert and SFINAE
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: piotr dot wyderski at gmail dot com
  GCC host triplet: GCC-4.4.0 (20090309), Cygwin, Windows XP


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413

Reply via email to