ros_comm icon indicating copy to clipboard operation
ros_comm copied to clipboard

Uninitialized member in ros::AdvertiseOptions

Open peci1 opened this issue 2 years ago • 0 comments

https://github.com/ros/ros_comm/blob/f1156c15a42482d5e762c9e7a2a307681a00adcf/clients/roscpp/include/ros/advertise_options.h#L43-L47

https://github.com/ros/ros_comm/blob/f1156c15a42482d5e762c9e7a2a307681a00adcf/clients/roscpp/include/ros/advertise_options.h#L131

Field has_header is of trivial type and the no-arg constructor does not initialize it. This has hit me with a hard-to-debug issue when creating advertiseoptions myself not using the all-arg constructor. If you create AdvertiseOptions using the no-arg constructor, has_header gets a random value and the code path in Publication tries to increment the seq field even if the message does not have a header.

Would a PR adding the missing initializer be accepted in Melodic and Noetic? I think adding an initializer should not break ABI or API.

peci1 avatar May 23 '22 09:05 peci1