Skip to content

Latest commit

 

History

History
11 lines (10 loc) · 779 Bytes

File metadata and controls

11 lines (10 loc) · 779 Bytes
title C26402
ms.date 09/04/2019
ms.topic conceptual
f1_keywords
C26402
helpviewer_keywords
C26402
ms.assetid b9d3d398-697a-4a5d-8bfe-9c667dffb90b

C26402 DONT_HEAP_ALLOCATE_MOVABLE_RESULT

To avoid confusion about whether a pointer owns an object, a function that returns a movable object should allocate it on the stack and return it by value instead of returning a heap-allocated object. If pointer semantics are required, then return a smart pointer instead of a raw pointer. See C++ Core Guidelines R.3: Warn if a function returns an object that was allocated within the function but has a move constructor. Suggest considering returning it by value instead.