From 3ba0ab113cd81705a3e5962ba807f30656987935 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 12 Dec 2018 19:01:46 +0000 Subject: COMPMID-1710: Avoid undefined behavior in GCC 8.2 Undefined behavior when pushing object which contain unique_ptr to a vector container. Vector dynamic resizing was making all the unique_ptr members of the inserted objects up to this point invalid. As a workaround, memory is reserved to avoid vector reallocation. Change-Id: I74f7641a7f36981ebe51720a924b865bb7f54c91 Reviewed-on: https://review.mlplatform.org/390 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez --- arm_compute/graph/Workload.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'arm_compute/graph') diff --git a/arm_compute/graph/Workload.h b/arm_compute/graph/Workload.h index e9368eefd0..682b08d88d 100644 --- a/arm_compute/graph/Workload.h +++ b/arm_compute/graph/Workload.h @@ -69,6 +69,20 @@ public: */ struct ExecutionTask { + ExecutionTask(std::unique_ptr &&f, INode *n) + : task(std::move(f)), node(n) + { + } + /** Prevent instances of this class from being copied (As this class contains pointers) */ + ExecutionTask(const ExecutionTask &) = delete; + /** Prevent instances of this class from being copied (As this class contains pointers) */ + ExecutionTask &operator=(const ExecutionTask &) = delete; + /** Default Move Constructor. */ + ExecutionTask(ExecutionTask &&) noexcept = default; + /** Default move assignment operator */ + ExecutionTask &operator=(ExecutionTask &&) noexcept = default; + /** Default destructor */ + ~ExecutionTask() = default; // TODO (geopin01) : Support vector of functions? std::unique_ptr task = {}; /**< Task to execute */ INode *node = {}; /**< Node bound to this workload */ -- cgit v1.2.1