[
https://issues.apache.org/jira/browse/PROTON-1216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15310673#comment-15310673
]
Chuck Rolke commented on PROTON-1216:
-------------------------------------
This commit set generates 103 warnings on a windows 2013 x64 build.
{noformat}
22>d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./internal/type_traits.hpp(164):
warning C4244: 'argument' : conversion from 'const float' to 'const int64_t',
possible loss of data
22>
d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./internal/scalar_base.hpp(171)
: see reference to class template instantiation
'proton::internal::is_convertible<From,To>' being compiled
22> with
22> [
22> From=float,
22> To=int64_t
22> ]
22>
d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./internal/scalar_base.hpp(197)
: see reference to function template instantiation 'R
proton::internal::visit<T,proton::internal::coerce_op<T>>(const
proton::internal::scalar_base &,F)' being compiled
22> with
22> [
22> R=int64_t,
22> T=int64_t,
22> F=proton::internal::coerce_op<int64_t>
22> ]
22>
d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./value.hpp(151)
: see reference to function template instantiation 'T
proton::internal::coerce<T>(const proton::internal::scalar_base &)' being
compiled
22> with
22> [
22> T=int64_t
22> ]
22>
d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./value.hpp(139)
: see reference to function template instantiation 'void
proton::coerce<T>(const proton::value &,T &)' being compiled
22> with
22> [
22> T=int64_t
22> ]
22>
d:\users\crolke\git\qpid-proton\proton-c\bindings\cpp\include\proton\./value.hpp(163)
: see reference to function template instantiation 'T
proton::coerce<int64_t>(const proton::value &)' being compiled
22> with
22> [
22> T=int64_t
22> ]
{noformat}
That's 103 warnings of 29 lines each for about 3,000 lines of clutter in a
build log.
How do we fix this? Suppressing warning C4244 is one way but undesirable.
> c++: proton::coerce<std::string>() should allow conversion from binary.
> -----------------------------------------------------------------------
>
> Key: PROTON-1216
> URL: https://issues.apache.org/jira/browse/PROTON-1216
> Project: Qpid Proton
> Issue Type: Bug
> Components: cpp-binding
> Affects Versions: 0.12.2
> Reporter: Alan Conway
> Assignee: Alan Conway
> Fix For: 0.13.0
>
>
> proton::coerce<std::string> should convert a binary value to a std::string.
> The documentation also needs clarification: coerce should allow exactly those
> conversions that are allowed as implicit C++ conversions.
> Issue raised in excellent bug report on the user list
> http://qpid.2158936.n2.nabble.com/Proton-C-0-13-x-decode-binary-type-tp7644510p7644747.html
> text follows:
> proton::coerce (both forms) currently throws the same
> exception as proton::get, as does value.as_string(), although that doesn't
> appear to be in the public API. Not sure what 'd' was in the d>>b example,
> but got a version working using value.get<std::binary>() and an implicit
> cast to std::string.
> To reproduce...
> #include <proton/value.hpp>
> #include <proton/binary.hpp>
> #include <proton/error.hpp>
> #include <iostream>
> template<typename Lambda>
> void expect_exception ( Lambda f )
> {
> try
> {
> f();
> std::cout << "*** FAIL (expected conversion error) ***" << std::endl;
> }
> catch ( const proton::conversion_error& e )
> {
> std::cout << "PASS" << std::endl;
> }
> }
> template<typename Lambda>
> void expect_value ( const std::string& expected, Lambda f )
> {
> try
> {
> std::cout << (f() == expected ? "PASS" : "*** FAIL (wrong value) ***")
> << std::endl;
> }
> catch ( const proton::conversion_error& e )
> {
> std::cout << "*** FAIL (conversion error) ***" << std::endl;
> }
> }
> int main()
> {
> std::string expected = "Hello World!";
> proton::value value = proton::binary(expected);
> expect_exception( [=] { return value.get<std::string>();
>
> });
> expect_exception( [=] { return proton::get<std::string>(value);
>
> });
> expect_exception( [=] { std::string result;
> proton::get<std::string>(value); return result; });
> expect_value(expected, [=] () -> std::string { return
> value.get<proton::binary>(); } );
> // The following currently fail under 0.13.x
> expect_value(expected, [=] { return value.as_string();
>
> });
> expect_value(expected, [=] { return proton::coerce<std::string>(value);
>
> });
> expect_value(expected, [=] { std::string result;
> proton::coerce<std::string>(value, result); return result; });
>
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]