OSDN Git Service
libpdx: Fix bug in Variant type.
Fix a subtle bug in the Variant value destruction along the
EmptyVariant assignment path:
some_variant = EmptyVariant{};
The problem arises from the private utility method Destruct(),
which does not set the type index to "empty" after destroying the
current sub-element. For most paths this is okay because the type
index is immediately set to the new sub-element type. However, the
EmptyVariant path does not assign a new type because the Variant
should become empty. Since the type is not set to "empty" the
Variant incorrectly double destroys the previous value when a new
value is assigned.
Also clean up a superfluous overload of Assign() that is skipped
due to the stronger binding of the universal reference overload
Assign(T&&).
Update tests to properly cover this case. In the process discovered
two incorrect tests related to this issue and updated them.
Bug: None
Test: pdx_tests passes.
Change-Id: I106f863b34f2719820d04d0e701968332f659c3e