You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code-quality/c6392.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,54 +7,54 @@ helpviewer_keywords: ["C6392"]
7
7
---
8
8
# Warning C6392
9
9
10
-
> This expression will write the value of the pointer to the stream; if this is intentional, add an explicit cast to 'void *'
10
+
> This expression writes the value of the pointer to the stream. If this is intentional, add an explicit cast to 'void *'
11
11
12
12
This rule was added in Visual Studio 2022 17.8.
13
13
14
14
## Remarks
15
15
16
-
In C++, we have streams of wide characters, like `std::wostringstream`, and streams of nonwide characters like`std::ostringstream`. Trying to print a wide character literal to a nonwide string calls the `void*` overload of `operator<<`. This overload prints the address of the wide string literal instead of the value.
16
+
C++ supports wide character streams such as `std::wostringstream`, and nonwide character streams such as`std::ostringstream`. Trying to print a wide string literal to a nonwide stream calls the `void*` overload of `operator<<`. This overload prints the address of the wide string literal instead of the value.
17
17
18
18
Code analysis name: `STREAM_OUTPUT_VOID_PTR`
19
19
20
20
## Example
21
21
22
-
In the following code snippet, we print the value of the pointer to the standard output instead of the string `"Foo"`:
22
+
The following code snippet prints the value of the pointer to the standard output instead of the string `"Pear"`:
23
23
24
24
```cpp
25
25
#include<iostream>
26
26
27
27
intmain() {
28
-
std::cout << L"Foo\n"; // Warning: C6392
28
+
std::cout << L"Pear\n"; // Warning: C6392
29
29
}
30
30
```
31
31
32
-
There are multiple ways to fix this error. If printing the pointer value is unintended, we can use a nonwide string literal:
32
+
There are multiple ways to fix this error. If printing the pointer value is unintended, one can use a nonwide string literal:
33
33
34
34
```cpp
35
35
#include<iostream>
36
36
37
37
intmain() {
38
-
std::cout << "Foo\n"; // No warning.
38
+
std::cout << "Pear\n"; // No warning.
39
39
}
40
40
```
41
41
42
-
Alternatively, we can use a wide stream:
42
+
Alternatively, one can use a wide stream:
43
43
44
44
```cpp
45
45
#include<iostream>
46
46
47
47
intmain() {
48
-
std::wcout << L"Foo\n"; // No warning.
48
+
std::wcout << L"Pear\n"; // No warning.
49
49
}
50
50
```
51
51
52
-
If the behavior is intentional, we can silence the warning using an explicit cast:
52
+
If the behavior is intentional, silence the warning by using an explicit cast:
53
53
54
54
```cpp
55
55
#include<iostream>
56
56
57
57
intmain() {
58
-
std::cout << static_cast<void*>(L"Foo\n"); // No warning.
58
+
std::cout << static_cast<void*>(L"Pear\n"); // No warning.
0 commit comments