cocaine/cocaine-core

i386 + gcc 4.6 build is broken

redbaron opened this issue · 9 comments

default i386 ubuntu 12.04 can't compile it without removing '-Werror'

/usr/bin/g++   -Dcocaine_core_EXPORTS -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall -fPIC -I/home/user/elliptics/cocaine-core/include -I/home/user/elliptics/cocaine-core/foreign/cppzmq -I/home/user/elliptics/cocaine-core/foreign/backward-cpp -I/home/user/elliptics/cocaine-core/foreign/jsoncpp-0.6.0-rc2/include    -std=c++0x -W -Wall -Werror -pedantic -o CMakeFiles/cocaine-core.dir/src/essentials/services/logging.cpp.o -c /home/user/elliptics/cocaine-core/src/essentials/services/logging.cpp
In file included from /home/user/elliptics/cocaine-core/include/cocaine/dispatch.hpp:25:0,
                 from /home/user/elliptics/cocaine-core/include/cocaine/api/service.hpp:25,
                 from /home/user/elliptics/cocaine-core/include/cocaine/essentials/services/logging.hpp:24,
                 from /home/user/elliptics/cocaine-core/src/essentials/services/logging.cpp:21:
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp: In static member function 'static typename cocaine::detail::result_of<F>::type cocaine::invoke<Sequence>::apply(const F&, const msgpack::object&) [with F = std::function<cocaine::logging::priorities()>, Sequence = boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, typename cocaine::detail::result_of<F>::type = cocaine::logging::priorities]':
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp:180:9:   instantiated from 'void cocaine::blocking_slot<R, Sequence>::operator()(const stream_ptr_t&, const msgpack::object&) [with R = cocaine::logging::priorities, Sequence = boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, cocaine::api::stream_ptr_t = std::shared_ptr<cocaine::api::stream_t>]'
/home/user/elliptics/cocaine-core/src/essentials/services/logging.cpp:42:1:   instantiated from here
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp:104:9: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp: In static member function 'static typename cocaine::detail::result_of<F>::type cocaine::invoke<Sequence>::apply(const F&, const msgpack::object&) [with F = std::function<void(cocaine::logging::priorities, std::basic_string<char>, std::basic_string<char>)>, Sequence = boost::mpl::list<cocaine::logging::priorities, std::basic_string<char>, std::basic_string<char> >, typename cocaine::detail::result_of<F>::type = void]':
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp:212:9:   instantiated from 'void cocaine::blocking_slot<void, Sequence>::operator()(const stream_ptr_t&, const msgpack::object&) [with Sequence = boost::mpl::list<cocaine::logging::priorities, std::basic_string<char>, std::basic_string<char> >, cocaine::api::stream_ptr_t = std::shared_ptr<cocaine::api::stream_t>]'
/home/user/elliptics/cocaine-core/src/essentials/services/logging.cpp:42:1:   instantiated from here
/home/user/elliptics/cocaine-core/include/cocaine/slot.hpp:104:9: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]

I don't have a 32-bit gcc 4.4-based system around, could you please verify this?

I mean, 4.6.

Thanks, it fixed it, but backwards-cpp has non portable snippet:

fprintf(os, "%4lu: %s\n", it->first, it->second.c_str());

where it->first is of size_t type. Having if (sizeof(size_t)) branching can be an option, but doesn't feel right. "%zu" can't be used in C++ :( I am not familiar with C++, is there any way to build iostream from stdio's FILE* ? If yes, then all printfs can be replaced with cleaner (arguably) iostream counterparts.

Sorry, problem arises on line 1943 of backwards.hpp

I never heard that %zu can't be used in C++. Why? It looks like a perfect way to print size_t values, and its rather portable (works in Linux, Mac and I guess on FreeBSD too, which is enough).

It was new to me too:

/home/user/elliptics/cocaine-core/foreign/backward-cpp/backward.hpp:1943:59: error: ISO C++ does not support the 'z' gnu_printf length modifier [-Werror=format]

I'm building with GCC 4.6.3 on 64-bit Ubuntu Precise with -W -Wall -Werror -pedantic and get no such errors. Could you show your compiler invocation string which generated this error? Or maybe you use some kind of non-standard compiler/system configuration I should know about?

You have no such error with %zu? Or with %lu, which is currently in the code and works ok for 64 bit.

It is default ubuntu precise 12.04 32bit, nothing fancy there.

Ah, you changed it to %zu and it started to fail, now I get it. I guess the original problem is that they use %li there and it breaks on 32-bit systems? We don't generally do 32-bit builds at all, so we don't see these errors. I think, it's possible to submit a patch to backward-cpp authors with some branching on sizeof(size_t) which seems like the easiest solution. Or we can locally disable this warning with a pragma.