From: Francisco Jerez Date: Tue, 14 Jan 2014 21:03:57 +0000 (+0100) Subject: clover: Fix clover::keys and ::values to deal with r-value references properly. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd6266622415fd24016f5c8e47c8b9cb654ea089;p=mesa.git clover: Fix clover::keys and ::values to deal with r-value references properly. Returning a reference is incorrect if the specified pair was a temporary -- Instead of that, use decltype() to deduce the correct return type qualifiers. Fixes a crash in clCreateProgramWithBinary(). Reported-and-tested-by: "Dorrington, Albert" --- diff --git a/src/gallium/state_trackers/clover/util/functional.hpp b/src/gallium/state_trackers/clover/util/functional.hpp index 8e0b483a78f..2d8c4c44131 100644 --- a/src/gallium/state_trackers/clover/util/functional.hpp +++ b/src/gallium/state_trackers/clover/util/functional.hpp @@ -289,17 +289,17 @@ namespace clover { struct keys { template - typename std::remove_reference

::type::first_type & - operator()(P &&p) const { - return p.first; + auto + operator()(P &&p) const -> decltype(std::get<0>(std::forward

(p))) { + return std::get<0>(std::forward

(p)); } }; struct values { template - typename std::remove_reference

::type::second_type & - operator()(P &&p) const { - return p.second; + auto + operator()(P &&p) const -> decltype(std::get<1>(std::forward

(p))) { + return std::get<1>(std::forward

(p)); } };