+rtrieu

On Fri, Jun 12, 2015 at 3:53 PM, Ismail Pazarbasi <
[email protected]> wrote:

> Hi rsmith, dblaikie,
>
> If a member of type unique_ptr or shared_ptr is move-constructed from
> a parameter in ctor-init, the parameter will be left with nullptr at
> the completion of member's initialization. If the parameter's and
> member's names are the same, use of member's name in the constructor
> body will not refer to the member, but to the parameter.
>
>   #include <memory>
>   struct X {
>     int v;
>     X() : v() { }
>     int f() { return v + 42; }
>   };
>
>   struct Y {
>     std::unique_ptr<X> p;
>     int x;
>     explicit Y(std::unique_ptr<X> p)
>       : p{std::move(p)} {
>       x = p->f();  // 'p' is nullptr
>       decltype(p->f()) v = x; // ignore unevaluated context
>     }
>     int f() const { return x; }
>   };
>
>   int main() {
>     std::unique_ptr<X> p(new X);
>     Y y(std::move(p));
>     return y.f();
>   }
>
> http://reviews.llvm.org/D10425
>
> Files:
>   include/clang/Basic/DiagnosticGroups.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/Sema/SemaDecl.cpp
>   test/SemaCXX/rval-references.cpp
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to