We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 10d9a37 commit 2acb092Copy full SHA for 2acb092
docs/error-messages/compiler-warnings/compiler-warning-level-1-c4172.md
@@ -22,13 +22,22 @@ The following example generates C4172:
22
```cpp
23
// C4172.cpp
24
// compile with: /c /W1
25
+
26
+const int* func1()
27
+{
28
+ int i = 42;
29
+ return &i; // C4172
30
+}
31
32
float f = 1.f;
33
-const double& func()
34
+const double& func2()
35
// Try one of the following lines instead:
-// const float& func()
-// const auto& func()
36
+// const float& func2()
37
+// const auto& func2()
38
{
39
+ // The problem is that a temporary is created to convert f to a double.
40
+ // C4172 in this case refers to returning the address of a temporary
41
return f; // C4172
42
}
43
```
0 commit comments