Skip to content

Commit b973448

Browse files
authored
Merge pull request #5735 from MicrosoftDocs/main
1/15/2025 AM Publish
2 parents 700ff22 + 848b1e4 commit b973448

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/code-quality/c33001.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ helpviewer_keywords: ["C33001"]
1313
1414
## Remarks
1515

16-
This warning is triggered when an uninitialized `VARIANT` is passed to an API such as `VariantClear`
17-
that expects an initialized `VARIANT`.
16+
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.
17+
18+
This warning applies to these functions:
19+
20+
* `VariantClear`
21+
* `PropVariantClear`
22+
* `VariantCopy`
23+
* `VariantCopyInd`
24+
* `VariantChangeType`
25+
* `VariantChangeTypeEx`
26+
* `DestroyPropVariant`
1827

1928
Code analysis name: `VARIANTCLEAR_UNINITIALIZED`
2029

2130
## Example
2231

23-
The following sample code causes warning C33001:
32+
The following code causes warning C33001:
2433

2534
```cpp
2635
#include <Windows.h>
@@ -36,11 +45,11 @@ HRESULT foo(bool some_condition)
3645
//...
3746
}
3847

39-
VariantClear(&var); // C33001
48+
VariantClear(&var); // C33001
4049
}
4150
```
4251
43-
These warnings are corrected by ensuring `VariantClear` is called only for a properly initialized `VARIANT`:
52+
In this example, the warning is corrected by calling `VariantClear` only after `var` has been initialized:
4453
4554
```cpp
4655
#include <Windows.h>
@@ -54,12 +63,12 @@ HRESULT foo(bool some_condition)
5463
//...
5564
VariantInit(&var);
5665
//...
57-
VariantClear(&var); // C33001
66+
VariantClear(&var); // OK
5867
}
5968
}
6069
```
6170

6271
## See also
6372

64-
[C33004](./c33004.md)
73+
[C33004](./c33004.md)\
6574
[C33005](./c33005.md)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy