Bug 22487 – Array!T.init.data crashes

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-11-07T16:29:40Z
Last change time
2021-11-09T09:10:04Z
Keywords
pull
Assigned to
No Owner
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2021-11-07T16:29:40Z
The fix for issue 21100 is buggy, the following code crashes: --- void main(){ import std.container; Array!int a; foreach(i;a.data){} } --- core.exception.AssertError@std/typecons.d(6644): Attempted to access an uninitialized payload. --- It should check whether the data is initialized, like most other members of Array!T do. If the data is not initialized, it should return an empty dynamic array.
Comment #1 by dlang-bot — 2021-11-07T17:43:06Z
@MoonlightSentinel created dlang/phobos pull request #8310 "Fix 22487 - Don't access payload for unititialized array data" fixing this issue: - Fix 22487 - Don't access payload for unititialized array data Explicitly return `[]` when `store` wasn't intialized yet. https://github.com/dlang/phobos/pull/8310
Comment #2 by dlang-bot — 2021-11-08T05:40:14Z
dlang/phobos pull request #8310 "Fix 22487 - Don't access payload for unititialized array data" was merged into stable: - 61eb40b0c9b2aebf386a220ce2bc269552ba29fa by MoonlightSentinel: Fix 22487 - Don't access payload for unititialized array data Explicitly return `[]` when `store` wasn't intialized yet. https://github.com/dlang/phobos/pull/8310
Comment #3 by dlang-bot — 2021-11-09T09:10:04Z
dlang/phobos pull request #8313 "Merge `stable` in `mater`" was merged into master: - c0981769a06bd3a011fd4760d88a39b590659685 by MoonlightSentinel: Fix 22487 - Don't access payload for unititialized array data Explicitly return `[]` when `store` wasn't intialized yet. https://github.com/dlang/phobos/pull/8313