Variant: Do not use implicit fall-through
The code handling the comparison between the date and string types would convert the variants to correct types, but only through multi-level fall-through in the switch statement, which is always a bit of a dangerous construct. Added explicit return for the non-trivial case, preventing the need for the fall-through. Closes #2502.
This commit is contained in:
@@ -1098,8 +1098,15 @@ bool Variant::operator_partial (const Variant& other) const
|
|||||||
{
|
{
|
||||||
// Same-day comparison.
|
// Same-day comparison.
|
||||||
case type_string:
|
case type_string:
|
||||||
if (left.trivial () || right.trivial ())
|
{
|
||||||
return false;
|
if (left.trivial () || right.trivial ())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
right.cast (type_date);
|
||||||
|
Datetime left_date (left._date);
|
||||||
|
Datetime right_date (right._date);
|
||||||
|
return left_date.sameDay (right_date);
|
||||||
|
}
|
||||||
|
|
||||||
case type_boolean:
|
case type_boolean:
|
||||||
case type_integer:
|
case type_integer:
|
||||||
|
|||||||
Reference in New Issue
Block a user