What happened
Building dynamixel_workbench_toolbox (ROS 2 Humble, GCC on Ubuntu 22.04, default -Wall -Wextra -Wpedantic-style flags via colcon) emits two -Wvla warnings:
dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp: In member function ‘bool DynamixelDriver::readRegister(uint8_t, uint16_t, uint16_t, uint32_t*, const char**)’:
dynamixel_driver.cpp:776:11: warning: ISO C++ forbids variable length array ‘data_read’ [-Wvla]
776 | uint8_t data_read[length];
| ^~~~~~~~~
dynamixel_driver.cpp: In member function ‘bool DynamixelDriver::syncWrite(uint8_t, uint8_t*, uint8_t, int32_t*, uint8_t, const char**)’:
dynamixel_driver.cpp:1012:11: warning: ISO C++ forbids variable length array ‘multi_parameter’ [-Wvla]
1012 | uint8_t multi_parameter[4*data_num_for_each_id];
| ^~~~~~~~~~~~~~~
The same code is present on main at lines 772 and 1009 of
interbotix_ros_xseries/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp.
Why it matters
Variable-length arrays are a C99 feature, not part of any C++ standard; GCC only accepts them as an extension. Besides the warning noise in every downstream build (colcon surfaces the package under a --- stderr: block), a large runtime length can silently overflow the stack.
Suggested fix
Replace the VLAs with std::vector<uint8_t>:
std::vector<uint8_t> data_read(length);
...
std::vector<uint8_t> multi_parameter(4 * data_num_for_each_id);
The buffers are passed to the Dynamixel SDK as uint8_t*, so data_read.data() drops in without further changes.
Happy to open a PR if the fix is welcome.
What happened
Building
dynamixel_workbench_toolbox(ROS 2 Humble, GCC on Ubuntu 22.04, default-Wall -Wextra -Wpedantic-style flags via colcon) emits two-Wvlawarnings:The same code is present on
mainat lines 772 and 1009 ofinterbotix_ros_xseries/dynamixel_workbench_toolbox/src/dynamixel_workbench_toolbox/dynamixel_driver.cpp.Why it matters
Variable-length arrays are a C99 feature, not part of any C++ standard; GCC only accepts them as an extension. Besides the warning noise in every downstream build (colcon surfaces the package under a
--- stderr:block), a large runtimelengthcan silently overflow the stack.Suggested fix
Replace the VLAs with
std::vector<uint8_t>:The buffers are passed to the Dynamixel SDK as
uint8_t*, sodata_read.data()drops in without further changes.Happy to open a PR if the fix is welcome.