Errors in handling of boost::asio errors ('boost' was compiled with wrong std::string representation?)

Роман rod1gin@ngs.ru
Mon Nov 23 16:32:00 GMT 2015


John Hein wrote at 10:22 -0700 on Nov 22, 2015:
> Use 'size=%zu'.  And get into the habit of compiling with -Wall

1) My apology for inaccuracy.
2) Usually, I use -Wall, but omits it for brevity.
3) GCC cannot warn for "%zu" - "%lu" mismatch. But it can 
warn if I confuse "%u" with "%s".
4) The problem is still here:

--------------- begin of the code
#include <stdio.h>
#include <boost/asio.hpp>

int main()
{
     boost::asio::ip::address_v4 a;
     boost::system::error_code ec;
     a.from_string("127.0.0.1111", ec);

     std::string s = ec.message();

     printf("size=%zu, c_str=\"%s\".\n",
             s.size(),
             s.c_str());

     return 0;
}
--------------- end of the code

--------------- begin of the output
size=6444086549, c_str="Invalid argument".
--------------- end of the output

Windows 7, 64-bit, russian language.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list