-
-
Notifications
You must be signed in to change notification settings - Fork 411
[Trivial] Fix deprecated use of delete(x) in favor of x.destroy() #2104
Conversation
|
Thanks for your pull request and interest in making D better, @dkgroot! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
Hm... this isn't the same. |
|
@schveiguy any suggestion on how to get rid of: During compilation of druntime ? |
|
Sorry for the lack of response. Indeed, that message is not enough. What it really should say is "you should use destroy, and don't worry about freeing the memory, the GC will do it for you", as that is really the safe route. But often you want to free the memory. So really the answer is However, in this case, there is no allocation, so you just want to free the (null) pointers. Destroying them does nothing. You will have the same effect as using delete (the functions will be called), and the warning should go away. |
|
@schveiguy Thanks for the clarification ! |
|
Filed an issue about the diagnostic message: https://issues.dlang.org/show_bug.cgi?id=18505 |
|
As you may notice there, I forgot there is actually a new function that does the same as delete: https://dlang.org/phobos-prerelease/core_memory.html#.__delete, But I think at this point, just calling GC.free should be enough here. |
|
@schveiguy Are you going to fix/update druntime to use either one of these two solutions ? |
|
Possibly, but you could do it as well. |
|
Please note that Please use UPDATE: Also, all instances of |
OK, I remember now. It's because |
|
@JinShil Good question, don't have an answer for it though. Please compile druntime manually to see them popping up. Maybe deprecation does not care about version(none) ?? |
|
@JinShil
That concerns me a bit as well, as any changes we make will not actually be tested. But at this point, I'm not worried about this code, we should just get rid of the deprecation warning. |
Does Also, it looks like that block of code is just a test to exercise each function. Due to the fact that it is in a |
|
Actually, looking at the disassembly, So I would recommend, we just comment this whole thing out. The only other alternative is to directly call the runtime functions, which is such a low level detail that I don't think it's reasonable to assume they will not change in the future. The ping @WalterBright as he seems to have committed this code 3 years ago. BTW, since the commit has gone away, there is no real reference to what we are talking about. Here are the offending lines: Lines 43 to 50 in 2d87bb9
|
|
BTW you might also be interested in #1982 which adds |
Interesting. When I first implemented I assumed that
👍 |
No description provided.