Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.08 KB

c33004.md

File metadata and controls

53 lines (40 loc) · 1.08 KB
title description author ms.author ms.date f1_keywords helpviewer_keywords
Warning C33004
C33004 warning for VARIANTs
hwisungi
hwisungi
06/20/2020
C33004
VARIANTCLEAR_UNINITOUTPARAM
C33004

Warning C33004

VARIANT 'var', which is marked as _Out_ was cleared before being initialized (expression 'expr')

Remarks

This warning is triggered when a VARIANT parameter with _Out_ SAL annotation may not have been initialized on input, and is then passed to an API such as VariantClear that expects an initialized VARIANT.

Code analysis name: VARIANTCLEAR_UNINITOUTPARAM

Example

The following sample code causes warning C33004:

#include <Windows.h>

void t2(_Out_ VARIANT* pv)
{
    // ......
    VariantClear(pv);   // C33004
    // ......
}

These warnings are corrected by ensuring VariantClear is called only for a properly initialized VARIANT:

#include <Windows.h>

void t2(_Out_ VARIANT* pv)
{
    VariantInit(pv);
    // ......
    VariantClear(pv);   // OK
    // ......
}

See also

C33001 C33005