Hello,

While compiling the unit tests of Proton-c 0.12.2 on Visual Studio 2008 in
Debug mode, the cpp_scalar_test and cpp_value_test are failing with the
error: "C++ vector subscript out of range" 
After debugging, It seems that we try to cast the first element of a vector
and the test has an empty vector which is causing the issue.

The test fails for the following values:

    try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch
(conversion_error) {}
    try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch
(conversion_error) {}
    try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch
(conversion_error) {}
    try { get<std::string>(V(binary())); FAIL("binary as string"); } catch
(conversion_error) {}
    try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch
(conversion_error) {}

string, binary and symbol default constructor will construct an empty
vector.

So in types_internal.hpp, we do: pn_bytes_t b = { s.size(),
reinterpret_cast<const char*>(&s[0]) };
"s" is the empty vector so "s[0]" will throw the exception observed

I have done a workaround  in the attached patch and the test is green now.
But I think a clean fix is needed to prevent such error in production mode,
no?

Regards,
Adel

0001-Add-default-values-to-string-binary-and-symbol-to-av.patch
<http://qpid.2158936.n2.nabble.com/file/n7644983/0001-Add-default-values-to-string-binary-and-symbol-to-av.patch>
  



--
View this message in context: 
http://qpid.2158936.n2.nabble.com/Proton-C-0-12-2-C-vector-subscript-out-of-range-in-unit-tests-tp7644983.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

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

Reply via email to