Warning C33001
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 expects an initialized VARIANT
.
Code analysis name: VARIANTCLEAR_UNINITIALIZED
Example
The following sample code causes warning C33001:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
}
VariantClear(&var); // C33001
}
These warnings are corrected by ensuring VariantClear
is called only for a properly initialized VARIANT
:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
VariantClear(&var); // C33001
}
}