diff --git a/docs/code-quality/c33001.md b/docs/code-quality/c33001.md index d3208941b45..679ffc1e04c 100644 --- a/docs/code-quality/c33001.md +++ b/docs/code-quality/c33001.md @@ -13,14 +13,23 @@ helpviewer_keywords: ["C33001"] ## Remarks -This warning is triggered when an uninitialized `VARIANT` is passed to an API such as `VariantClear` -that expects an initialized `VARIANT`. +This warning is triggered when an uninitialized `VARIANT` is passed to an API, such as `VariantClear`, that clears the object. Initialize the `VARIANT` before passing it to these functions so it can be properly cleared. + +This warning applies to these functions: + +* `VariantClear` +* `PropVariantClear` +* `VariantCopy` +* `VariantCopyInd` +* `VariantChangeType` +* `VariantChangeTypeEx` +* `DestroyPropVariant` Code analysis name: `VARIANTCLEAR_UNINITIALIZED` ## Example -The following sample code causes warning C33001: +The following code causes warning C33001: ```cpp #include @@ -36,11 +45,11 @@ HRESULT foo(bool some_condition) //... } - VariantClear(&var); // C33001 + VariantClear(&var); // C33001 } ``` -These warnings are corrected by ensuring `VariantClear` is called only for a properly initialized `VARIANT`: +In this example, the warning is corrected by calling `VariantClear` only after `var` has been initialized: ```cpp #include @@ -54,12 +63,12 @@ HRESULT foo(bool some_condition) //... VariantInit(&var); //... - VariantClear(&var); // C33001 + VariantClear(&var); // OK } } ``` ## See also -[C33004](./c33004.md) +[C33004](./c33004.md)\ [C33005](./c33005.md)