boostorg / thread

Boost.org thread module
http://boost.org/libs/thread
198 stars 162 forks source link

Logic bug in detail::win32::create_event() #279

Closed chrullrich closed 5 years ago

chrullrich commented 5 years ago

https://github.com/boostorg/thread/blob/a645ef761ddf4c9811eb707c479363a79ae4534e/include/boost/thread/win32/thread_primitives.hpp#L105

The bitwise-or operator has higher precedence than the ternary, so this line compiles as

type ? create_event_manual_reset : ( ( 0 | state ) ? create_event_initial_set : 0 )

Creating an initially-set manual-reset event is therefore not possible. What is probably meant is:

( type ? create_event_manual_reset : 0 ) | ( state ? create_event_initial_set : 0 )
viboes commented 5 years ago

Right, thanks for the report.

PR is welcome.