Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
VARIANT 'var' was cleared when it was uninitialized (expression 'expr')
Remarks
This warning is triggered when an uninitialized VARIANT
is passed to an API, such as VariantClear
, that clears the object. Initialize the VARIANT
before passing it to these functions so it can be properly cleared.
This warning applies to these functions:
VariantClear
PropVariantClear
VariantCopy
VariantCopyInd
VariantChangeType
VariantChangeTypeEx
DestroyPropVariant
Code analysis name: VARIANTCLEAR_UNINITIALIZED
Example
The following code causes warning C33001:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
}
VariantClear(&var); // C33001
}
In this example, the warning is corrected by calling VariantClear
only after var
has been initialized:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
VariantClear(&var); // OK
}
}