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.
Actions