Skip to content

Latest commit

 

History

History
50 lines (40 loc) · 1008 Bytes

File metadata and controls

50 lines (40 loc) · 1008 Bytes
title c33004
description C33004 warning for VARIANTs
keywords c33004
author hwisungi
ms.author hwisungi
ms.date 06/20/2020
ms.topic reference
f1_keywords
C33004
helpviewer_keywords
C33004
dev_langs
C++

C33004

Warning C33004: VARIANT 'var', which is marked as Out was cleared before being initialized (expression 'expr')

This warning is triggered when a VARIANT parameter with _Out_ SAL annotation, which may haven't been initialized on input, is passed to an API such as VariantClear that expects an initialized VARIANT.

Example

#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