Repository: qpid-proton Updated Branches: refs/heads/master 822745298 -> ef37b2320
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/ef37b232 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ef37b232 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ef37b232 Branch: refs/heads/master Commit: ef37b23208f31bef224f82bc493867409f4aceeb Parents: 8227452 Author: Alan Conway <[email protected]> Authored: Tue Feb 2 15:08:12 2016 -0500 Committer: Alan Conway <[email protected]> Committed: Tue Feb 2 16:02:22 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/ef37b232/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/ef37b232/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 b8e3c39..9220fd7 100644 --- a/proton-c/bindings/cpp/src/condition.cpp +++ b/proton-c/bindings/cpp/src/condition.cpp @@ -44,7 +44,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/ef37b232/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/ef37b232/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]
