libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

static_cast error with poller=poll

Open delleceste opened this issue 5 years ago • 3 comments

Please use this template for reporting suspected bugs or requests for help.

Issue description

devel/libzmq/src/io_thread.cpp:41:22: error: static_cast from 'nullptr_t' to 'poller_t::handle_t' (aka 'int') is not allowed _mailbox_handle (static_cast<poller_t::handle_t> (NULL)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

Environment

  • libzmq version (commit hash if unreleased): master, 4.3.2, 4.3.1
  • OS: Openbsd

Minimal test code / Steps to reproduce the issue

What's the actual result? (include assertion message & call stack if applicable)

build fails

What's the expected result?

successful compilation

delleceste avatar Jun 14 '20 12:06 delleceste

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.

stale[bot] avatar Jun 26 '21 02:06 stale[bot]

Confirmed this is still an issue on openbsd 7.4 with libzmq-4.3.5. I'm building with cmake. autotools builds seem to work.

compilation command that fails in cmake:

/usr/bin/c++ -DZMQ_CUSTOM_PLATFORM_HPP -D_OPENBSD_SOURCE -D_REENTRANT -D_THREAD_
SAFE -I/root/zeromq-4.3.5/include -I/root/zeromq-4.3.5/build -std=c++11 -Wno-tau
tological-constant-compare -Wall -Wextra -Wno-long-long -Wno-uninitialized -O3 -
DNDEBUG -fPIC -MD -MT CMakeFiles/objects.dir/src/io_thread.cpp.o -MF CMakeFiles/
objects.dir/src/io_thread.cpp.o.d -o CMakeFiles/objects.dir/src/io_thread.cpp.o 
-c /root/zeromq-4.3.5/src/io_thread.cpp
/root/zeromq-4.3.5/src/io_thread.cpp:14:22: error: static_cast from 'nullptr_t' 
to 'poller_t::handle_t' (aka 'int') is not allowed
    _mailbox_handle (static_cast<poller_t::handle_t> (NULL))
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

equivalent compilation line that succeeds with autotools:

/bin/sh ./libtool  --tag=CXX   --mode=compile c++ -DHAVE_CONFIG_H -I. -I./src   
        -D_BSD_SOURCE -D_REENTRANT -D_THREAD_SAFE  -fvisibility=hidden     -Wall
 -Wno-long-long -g -O2 -c -o src/libzmq_la-io_thread.lo `test -f 'src/io_thread.
cpp' || echo './'`src/io_thread.cpp
libtool: compile:  c++ -DHAVE_CONFIG_H -I. -I./src -D_BSD_SOURCE -D_REENTRANT -D
_THREAD_SAFE -fvisibility=hidden -Wall -Wno-long-long -g -O2 -c src/io_thread.cp
p  -fPIC -DPIC -o src/.libs/libzmq_la-io_thread.o

Notably, the cmake platform.hpp has ZMQ_IOTHREAD_POLLER_USE_POLL, while autotools (correctly) has ZMQ_IOTHREAD_POLLER_USE_KQUEUE, which suggests the kqueue detection is not correct in cmake. I checked, and kqueue is found on mac.

Setting -DPOLLER=kqueue picks the right default and avoids the error. The error still exists if run with -DPOLLER=poll, or --with-poller=poll.

minrk avatar Feb 23 '24 12:02 minrk

#4659 avoids the error in default configuration when building with cmake by fixing the headers required to look for kqueue.

This error can be reproduced with autotools, built with --with-poller=poll

minrk avatar Feb 23 '24 12:02 minrk