nano::election::time_to_live has no default in case (causes compiler warning)
when I compile the code I get a compiler warning:
nano/node/election.cpp: In member function ‘std::chrono::milliseconds nano::election::time_to_live()’: nano/node/election.cpp:226:1: warning: control reaches end of non-void function [-Wreturn-type] 226 | }
the reason why is because the switch has no default behavior, even though all election_behavior cases are covered.
std::chrono::milliseconds nano::election::time_to_live ()
{
switch (behavior)
{
case election_behavior::normal:
return std::chrono::milliseconds (5 * 60 * 1000);
case election_behavior::optimistic:
return std::chrono::milliseconds (node.network_params.network.is_dev_network () ? 500 : 60 * 1000);
case election_behavior::hinted:
return std::chrono::milliseconds (30 * 1000);
}
}
code:
https://github.com/nanocurrency/nano-node/blob/33422f46e3fb46c3086278e2bdc411220133f3e2/nano/node/election.cpp#L225
list of election_behavior:
https://github.com/nanocurrency/nano-node/blob/33422f46e3fb46c3086278e2bdc411220133f3e2/nano/node/election.hpp#L43
Thanks for bringing attention to this issue, added a guard assert in https://github.com/nanocurrency/nano-node/pull/3863