Bug 20332 – associative array clear function should be @safe
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-10-28T21:11:52Z
Last change time
2023-11-16T10:23:52Z
Keywords
pull
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2019-10-28T21:11:52Z
If you look at the implementation of clear, it does not invalidate any items in the array. It just sets to null all the pointers to bucket items. The items themselves remain allocated, and any range that is pointing at a null bucket item will return null for the key or value, causing a null dereference (which is considered @safe).
Comment #1 by dlang-bot — 2023-11-15T16:24:28Z
@dkorpel created dlang/dmd pull request #15817 "Fix 20332 - associative array clear function should be @safe" fixing this issue:
- Fix 20332 - associative array clear function should be @safe
https://github.com/dlang/dmd/pull/15817
Comment #2 by dlang-bot — 2023-11-16T10:23:52Z
dlang/dmd pull request #15817 "Fix 20332 - associative array clear function should be @safe" was merged into master:
- f952d190e8fab236c2782c7d04dda58900dfc9ab by Dennis Korpel:
Fix 20332 - associative array clear function should be @safe
https://github.com/dlang/dmd/pull/15817