--- description: "Learn more about: Warning C26406 DONT_ASSIGN_RAW_TO_OWNER" title: Warning C26406 ms.date: 08/18/2020 f1_keywords: ["C26406", "DONT_ASSIGN_RAW_TO_OWNER"] helpviewer_keywords: ["C26406"] ms.assetid: 02fb8e23-1989-4e24-a5a5-e30f71d00325 --- # Warning C26406 > Do not assign a raw pointer to an `owner` (r.3) This warning enforces R.3 from the C++ Core Guidelines. For more information, see [C++ Core Guidelines R.3](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r3-a-raw-pointer-a-t-is-non-owning). ## Remarks Owners are initialized from allocations or from other owners. This warning occurs when you assign a value from a raw pointer to an owner pointer. Raw pointers don't guarantee ownership transfer; the original owner may still hold the resource and attempt to release it. It's okay to assign a value from an owner to a raw pointer. Raw pointers are valid clients to access resources, but not to manage them. Code analysis name: `DONT_ASSIGN_RAW_TO_OWNER` ## Example Using address of object: This sample attempts to assign ownership of the address of `defaultSocket` to owner pointer `socket`: ```cpp gsl::owner socket = defaultSocket ? &defaultSocket : new Socket(); // C26406 ```