void printMessage(const RosIntrospection::FlatMessage& flat_container)
{
for (auto& it : flat_container.value)
if (it.second.convert<std::uint8_t>()) // error value, of type franka_msgs::Errors::_tau_j_range_violation_type
ROS_ERROR(" - %s", it.first.toStdString().c_str()); // error name
}
with gcc 7.4.0 -Wall -O3 returns:
<...>/source.cpp: In function ‘void ns::printMessage(const RosIntrospection::FlatMessage&)’:
<...>/source.cpp:892:5: warning: ‘target’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (it.second.convert<std::uint8_t>())
Looking into it, I found -Wmaybe-uninitialized's cause and tried to see if I'm in that case, but I can't see any issues.
Now I'm not discounting being wrong, but if I add a default case to the convert function in variant.hpp, the warning disappears:
Also, I hadn't realized until this last copy-paste, but target is exactly the return variable of the convert function.
I'd actually suggest changing the OTHER type (actually most of the times I see enums, the last one is the total number of enumerated cases, i.e. an ALL_TYPES in this case. It'd probably be useless though) with the default case.
EDIT: no, not changing the OTHER type, but introducing the default where you anyways throw
Compiling
with gcc 7.4.0 -Wall -O3 returns:
Looking into it, I found -Wmaybe-uninitialized's cause and tried to see if I'm in that case, but I can't see any issues.
Now I'm not discounting being wrong, but if I add a default case to the convert function in variant.hpp, the warning disappears:
Also, I hadn't realized until this last copy-paste, but
target
is exactly the return variable of the convert function.I'd actually suggest changing the
OTHER
type (actually most of the times I see enums, the last one is the total number of enumerated cases, i.e. anALL_TYPES
in this case. It'd probably be useless though) with thedefault
case.EDIT: no, not changing the
OTHER
type, but introducing thedefault
where you anywaysthrow