Edit

Share via


Warning C33005

VARIANT 'var' was provided as an _In_ or _InOut_ parameter but was not initialized (expression 'expr')

Remarks

This warning is triggered when an uninitialized VARIANT is passed to a function as an input-only or input/output parameter. For example, a pass-by-reference parameter without an _Out_ SAL annotation.

Code analysis name: VARIANTCLEAR_UNINITFUNCPARAM

Example

The following sample code causes warning C33005:

#include <Windows.h>

void bar(VARIANT* v);   // v is assumed to be input/output

void foo()
{
    VARIANT v;
    bar(&v);            // C33005
    // ......
    VariantClear(&v);   // OK, assumed to be initialized by bar
}

To correct these warnings, initialize the VARIANT before passing it to a function as input-only or input/output.

#include <Windows.h>

void bar(VARIANT* v);   // v is assumed to be input/output

void foo()
{
    VARIANT v;
    VariantInit(&v);
    bar(&v);            // OK
    // ......
    VariantClear(&v);   // OK, assumed to be initialized by bar
}

See also

C33001 C33004