Actions
Bug #3497
closedMgmt/Nfd/TestControlCommand/Face{Enable,Disable}LocalControl undefined behavior
Start date:
Due date:
% Done:
0%
Estimated time:
2.00 h
Description
FaceEnableLocalControl and FaceDisableLocalControl test cases perform the following illegal cast:
static_cast<LocalControlFeature>(666)
This is undefined behavior because 666 is not within the range of the values of the enum type LocalControlFeature
. The standard says:
[expr.static.cast]
- A value of integral or enumeration type can be explicitly converted to a complete enumeration type. The value is unchanged if the original value is within the range of the enumeration values. Otherwise, the behavior is undefined.
[dcl.enum]
- For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type. Otherwise, for an enumeration where emin is the smallest enumerator and emax is the largest, the values of the enumeration are the values in the range bmin to bmax, defined as follows: Let K be 1 for a two's complement representation and 0 for a one's complement or sign-magnitude representation. bmax is the smallest value greater than or equal to max(|emin| − K, |emax|) and equal to 2M − 1, where M is a non-negative integer. bmin is zero if emin is non-negative and −(bmax + K) otherwise.
Updated by Junxiao Shi over 8 years ago
This is just another Halt-and-Catch-Fire bug.
I see no value in fixing it because (1) it works fine for now (2) the test case will be gone after #3226.
Updated by Davide Pesavento about 8 years ago
- Subject changed from ManagementNfdControlCommand/Face{Enable,Disable}LocalControl undefined behavior to Mgmt/Nfd/TestControlCommand/Face{Enable,Disable}LocalControl undefined behavior
- Target version deleted (
v0.5)
Updated by Junxiao Shi almost 8 years ago
- Target version set to v0.6
- Estimated time set to 2.00 h
The offending test case is still there because FaceEnableLocalControl
and FaceDisableLocalControl
commands are still there. I suggest deleting these deprecated commands. This solution is subject to approval at NFD call.
Updated by Junxiao Shi over 7 years ago
- Related to Bug #3974: Unsafe casts in ndn::nfd::*::wireDecode() added
Updated by Junxiao Shi over 7 years ago
- Status changed from New to Closed
The offending test cases are deleted in ndn-cxx:commit:e6835fe12b92b635a89fa641c2294647d5941af9
Actions