Mesa (master): clover: Fix clover::keys and :: values to deal with r-value references properly.

Francisco Jerez currojerez at kemper.freedesktop.org
Wed Jan 15 15:52:51 UTC 2014


Module: Mesa
Branch: master
Commit: bd6266622415fd24016f5c8e47c8b9cb654ea089
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd6266622415fd24016f5c8e47c8b9cb654ea089

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Tue Jan 14 22:03:57 2014 +0100

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" <albert.dorrington at lmco.com>

---

 src/gallium/state_trackers/clover/util/functional.hpp |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/clover/util/functional.hpp b/src/gallium/state_trackers/clover/util/functional.hpp
index 8e0b483a..2d8c4c4 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 P>
-      typename std::remove_reference<P>::type::first_type &
-      operator()(P &&p) const {
-         return p.first;
+      auto
+      operator()(P &&p) const -> decltype(std::get<0>(std::forward<P>(p))) {
+         return std::get<0>(std::forward<P>(p));
       }
    };
 
    struct values {
       template<typename P>
-      typename std::remove_reference<P>::type::second_type &
-      operator()(P &&p) const {
-         return p.second;
+      auto
+      operator()(P &&p) const -> decltype(std::get<1>(std::forward<P>(p))) {
+         return std::get<1>(std::forward<P>(p));
       }
    };
 




More information about the mesa-commit mailing list