C33001

Warning C33001: VARIANT 'var' was cleared when it was uninitialized (expression 'expr')

This warning is triggered when an uninitialized VARIANT is passed to an API such as VariantClear that expects an initialized VARIANT.

Example

#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
    }
}

See also

C33004 C33005