|
1 | | -error: a dangling pointer will be produced because the temporary `CString` will be dropped |
| 1 | +error: expression creates a dangling pointer to dropped temporary `CString` |
2 | 2 | --> $DIR/calls.rs:27:29 |
3 | 3 | | |
4 | 4 | LL | let ptr = cstring().as_ptr(); |
5 | | - | --------- ^^^^^^ this pointer will immediately be invalid |
| 5 | + | --------- ^^^^^^ dangling pointer created here |
6 | 6 | | | |
7 | | - | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime |
| 7 | + | this `CString` is dropped at the end of the statement |
8 | 8 | | |
9 | | - = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned |
10 | | - = help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr` |
11 | | - = help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice |
| 9 | + = help: bind the `CString` to a variable such that it outlives the pointer returned by `as_ptr` |
| 10 | + = help: returning a pointer to a local variable will always result in a dangling pointer |
12 | 11 | = help: for more information, see <https://doc.rust-lang.org/reference/destructors.html> |
| 12 | + = note: a dangling pointer is safe, but dereferencing one is undefined behavior |
13 | 13 | note: the lint level is defined here |
14 | 14 | --> $DIR/calls.rs:1:9 |
15 | 15 | | |
16 | 16 | LL | #![deny(dangling_pointers_from_temporaries)] |
17 | 17 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
18 | 18 |
|
19 | | -error: a dangling pointer will be produced because the temporary `CString` will be dropped |
| 19 | +error: expression creates a dangling pointer to dropped temporary `CString` |
20 | 20 | --> $DIR/calls.rs:32:29 |
21 | 21 | | |
22 | 22 | LL | let ptr = cstring().as_ptr(); |
23 | | - | --------- ^^^^^^ this pointer will immediately be invalid |
| 23 | + | --------- ^^^^^^ dangling pointer created here |
24 | 24 | | | |
25 | | - | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime |
| 25 | + | this `CString` is dropped at the end of the statement |
26 | 26 | | |
27 | | - = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned |
28 | | - = help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr` |
29 | | - = help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice |
| 27 | + = help: bind the `CString` to a variable such that it outlives the pointer returned by `as_ptr` |
| 28 | + = help: returning a pointer to a local variable will always result in a dangling pointer |
30 | 29 | = help: for more information, see <https://doc.rust-lang.org/reference/destructors.html> |
| 30 | + = note: a dangling pointer is safe, but dereferencing one is undefined behavior |
31 | 31 |
|
32 | | -error: a dangling pointer will be produced because the temporary `CString` will be dropped |
| 32 | +error: expression creates a dangling pointer to dropped temporary `CString` |
33 | 33 | --> $DIR/calls.rs:41:37 |
34 | 34 | | |
35 | 35 | LL | let _ptr: *const u8 = cstring().as_ptr().cast(); |
36 | | - | --------- ^^^^^^ this pointer will immediately be invalid |
| 36 | + | --------- ^^^^^^ dangling pointer created here |
37 | 37 | | | |
38 | | - | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime |
| 38 | + | this `CString` is dropped at the end of the statement |
39 | 39 | | |
40 | | - = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned |
41 | | - = help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr` |
42 | | - = help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice |
| 40 | + = help: bind the `CString` to a variable such that it outlives the pointer returned by `as_ptr` |
| 41 | + = help: returning a pointer to a local variable will always result in a dangling pointer |
43 | 42 | = help: for more information, see <https://doc.rust-lang.org/reference/destructors.html> |
| 43 | + = note: a dangling pointer is safe, but dereferencing one is undefined behavior |
44 | 44 |
|
45 | | -error: a dangling pointer will be produced because the temporary `CString` will be dropped |
| 45 | +error: expression creates a dangling pointer to dropped temporary `CString` |
46 | 46 | --> $DIR/calls.rs:43:41 |
47 | 47 | | |
48 | 48 | LL | let _ptr: *const u8 = { cstring() }.as_ptr().cast(); |
49 | | - | ------------- ^^^^^^ this pointer will immediately be invalid |
| 49 | + | ------------- ^^^^^^ dangling pointer created here |
50 | 50 | | | |
51 | | - | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime |
| 51 | + | this `CString` is dropped at the end of the statement |
52 | 52 | | |
53 | | - = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned |
54 | | - = help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr` |
55 | | - = help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice |
| 53 | + = help: bind the `CString` to a variable such that it outlives the pointer returned by `as_ptr` |
| 54 | + = help: returning a pointer to a local variable will always result in a dangling pointer |
56 | 55 | = help: for more information, see <https://doc.rust-lang.org/reference/destructors.html> |
| 56 | + = note: a dangling pointer is safe, but dereferencing one is undefined behavior |
57 | 57 |
|
58 | | -error: a dangling pointer will be produced because the temporary `CString` will be dropped |
| 58 | +error: expression creates a dangling pointer to dropped temporary `CString` |
59 | 59 | --> $DIR/calls.rs:45:39 |
60 | 60 | | |
61 | 61 | LL | let _ptr: *const u8 = { cstring().as_ptr() }.cast(); |
62 | | - | --------- ^^^^^^ this pointer will immediately be invalid |
| 62 | + | --------- ^^^^^^ dangling pointer created here |
63 | 63 | | | |
64 | | - | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime |
| 64 | + | this `CString` is dropped at the end of the statement |
65 | 65 | | |
66 | | - = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned |
67 | | - = help: you must make sure that the variable you bind the `CString` to lives at least as long as the pointer returned by the call to `as_ptr` |
68 | | - = help: in particular, if this pointer is returned from the current function, binding the `CString` inside the function will not suffice |
| 66 | + = help: bind the `CString` to a variable such that it outlives the pointer returned by `as_ptr` |
| 67 | + = help: returning a pointer to a local variable will always result in a dangling pointer |
69 | 68 | = help: for more information, see <https://doc.rust-lang.org/reference/destructors.html> |
| 69 | + = note: a dangling pointer is safe, but dereferencing one is undefined behavior |
70 | 70 |
|
71 | 71 | error: aborting due to 5 previous errors |
72 | 72 |
|
0 commit comments