[Bug libstdc++/48635] [C++0x] unique_ptr<T, D&> moves the deleter instead of copying it
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Sun Apr 17 20:12:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48635
--- Comment #8 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-17 20:12:09 UTC ---
(In reply to comment #7)
> Ok... Do we have testcases for that?
I have two test cases for the *assignment* situation, I invented them out of my
head and I hope the code below does not too many typos and thinkos:
1) This program should be well-formed according to FDIS wording, but ill-formed
according to the intended wording:
#include <memory>
#include <utility>
struct D;
struct B {
B& operator=(D&) = delete;
template<class T>
void operator()(T*) const {}
};
struct D : B {};
int main()
{
B b;
D d;
std::unique_ptr<void, B&> ub(nullptr, b);
std::unique_ptr<void, D&> ud(nullptr, d);
ub = std::move(ud); // Should be rejected
}
2) The same scenario here:
struct D2;
struct B2 {
B2& operator=(D2&) = delete;
template<class T>
void operator()(T*) const {}
};
struct D2 {
B2 b;
operator B2&() { return b; }
template<class T>
void operator()(T*) const {}
};
int main()
{
B2 b;
D2 d;
std::unique_ptr<void, B2&> ub(nullptr, b);
std::unique_ptr<void, D2&> ud(nullptr, d);
ub = std::move(ud); // Should be rejected
}
> By the way, I noticed that in the templated *constructor* we have been using D
> instead of E in the forward, and that doesn't seem correct vs the FDIS itself.
> What do you think? The below regtests fine:
I agree that the suggested fixes are necessary and they look correct to me.
More information about the Gcc-bugs
mailing list