Repository: qpid-proton
Updated Branches:
  refs/heads/0.12.x b1f461bf2 -> 5917bf8aa


PROTON-1116: Potential infinite recursion detected by VC++14 compiler

The problem is caused by the implicit conversion constructor in proton::value.
Made it explicit and fixed a few places that relied on it.

This is a simple fix for 0.12, a safer and more flexible encoding/decoding
system based on type-traits will be committed to master.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5c380018
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5c380018
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5c380018

Branch: refs/heads/0.12.x
Commit: 5c380018978e1b55b4c39b1a3aa75bc7a0ab29a8
Parents: b1f461b
Author: Alan Conway <[email protected]>
Authored: Tue Feb 2 15:08:12 2016 -0500
Committer: Andrew Stitcher <[email protected]>
Committed: Tue Feb 2 17:16:38 2016 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/include/proton/value.hpp | 7 +++++--
 proton-c/bindings/cpp/src/condition.cpp        | 2 +-
 proton-c/bindings/cpp/src/test_bits.hpp        | 5 +++++
 proton-c/bindings/cpp/src/value_test.cpp       | 8 ++++----
 4 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c380018/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp 
b/proton-c/bindings/cpp/include/proton/value.hpp
index 4076e99..b2c1c0b 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -45,8 +45,11 @@ class value : public comparable<value> {
     /// Copy a value.
     PN_CPP_EXTERN value& operator=(const value&);
 
-    /// Create a value from C++ type T.
-    template <class T> value(const T& x) : data_(proton::data::create()) { 
encode() << x; }
+    /// Explicit conversion from from C++ type T.
+    template <class T> explicit value(const T& x) : 
data_(proton::data::create()) { encode() << x; }
+
+    /// Allow implicit conversion from a proton::scalar.
+    value(const scalar& x) { encode() << x; }
 
     /// Create a value from C++ type T.
     template <class T> value& operator=(const T& x) { encode() << x; return 
*this; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c380018/proton-c/bindings/cpp/src/condition.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/condition.cpp 
b/proton-c/bindings/cpp/src/condition.cpp
index 221afcd..4910358 100644
--- a/proton-c/bindings/cpp/src/condition.cpp
+++ b/proton-c/bindings/cpp/src/condition.cpp
@@ -40,7 +40,7 @@ std::string condition::description() const {
 
 value condition::info() const {
     pn_data_t* t = pn_condition_info(condition_);
-    return t ? t : value();
+    return t ? value(t) : value();
 }
 
 std::string condition::str() const {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c380018/proton-c/bindings/cpp/src/test_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_bits.hpp 
b/proton-c/bindings/cpp/src/test_bits.hpp
index 39d4be5..f6297da 100644
--- a/proton-c/bindings/cpp/src/test_bits.hpp
+++ b/proton-c/bindings/cpp/src/test_bits.hpp
@@ -86,5 +86,10 @@ template <class T> std::ostream& operator<<(std::ostream& o, 
const std::vector<T
 template <class T> std::ostream& operator<<(std::ostream& o, const 
std::deque<T>& s) {
     return o << test::many<T>(s);
 }
+
+template <class U, class V> std::ostream& operator<<(std::ostream& o, const 
std::pair<U, V>& p) {
+    return o << "( " << p.first << " , " << p.second << " )";
+}
 }
+
 #endif // TEST_BITS_HPP

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5c380018/proton-c/bindings/cpp/src/value_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value_test.cpp 
b/proton-c/bindings/cpp/src/value_test.cpp
index b19ea76..cc94950 100644
--- a/proton-c/bindings/cpp/src/value_test.cpp
+++ b/proton-c/bindings/cpp/src/value_test.cpp
@@ -60,13 +60,13 @@ void map_test() {
     m["a"] = 1;
     m["b"] = 2;
     m["c"] = 3;
-    value v = m;
+    value v(m);
     ASSERT_EQUAL("{\"a\"=1, \"b\"=2, \"c\"=3}",  str(v));
     std::map<value, value> mv;
     v.get(mv);
-    ASSERT_EQUAL(mv["a"], value(amqp_int(1)));
-    mv["b"] = amqp_binary("xyz");
-    mv.erase("c");
+    ASSERT_EQUAL(mv[value("a")], value(amqp_int(1)));
+    mv[value("b")] = amqp_binary("xyz");
+    mv.erase(value("c"));
     v = value(mv);
     ASSERT_EQUAL("{\"a\"=1, \"b\"=b\"xyz\"}",  str(v));
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to