Bug 95 – foreach() over uninitalized AA yields Access Violation

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-04-08T16:04:56Z
Last change time
2021-05-27T12:58:15Z
Keywords
wrong-code
Assigned to
Walter Bright
Creator
Eric Anderton (aka Pragma)

Comments

Comment #0 by ericanderton — 2006-04-08T16:04:56Z
Under Windows, using foreach to iterate over an uninitalized AA generates an Access Violation. ////////////////////////// import std.stdio; void main(){ uint[char[]] foobar; foreach(value; foobar){} // fails on foreach }
Comment #1 by thomas-dloop — 2006-04-09T02:00:27Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-04-08: > http://d.puremagic.com/bugzilla/show_bug.cgi?id=95 > Under Windows, using foreach to iterate over an uninitalized AA generates an > Access Violation. > > ////////////////////////// > import std.stdio; > > void main(){ > uint[char[]] foobar; > foreach(value; foobar){} // fails on foreach > } Added to DStress as http://dstress.kuehne.cn/run/f/foreach_35_A.d http://dstress.kuehne.cn/run/f/foreach_35_B.d http://dstress.kuehne.cn/run/f/foreach_35_C.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEOLO93w+/yD4P9tIRAne3AKCXwPswPGm1bsXzgT7M1nyWFEerBACfQew2 mr8hcIW+GAmLszLrEW5kwDM= =p/7L -----END PGP SIGNATURE-----
Comment #2 by smjg — 2006-04-09T06:52:36Z
I experimented with this a bit after it broke a bit of SDWF. It happens only if the AA is actually uninitialised - if you've added something to the AA and then deleted it then it behaves correctly.
Comment #3 by thomas-dloop — 2006-04-09T15:00:18Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-04-09: > http://d.puremagic.com/bugzilla/show_bug.cgi?id=95 > ------- Comment #2 from [email protected] 2006-04-09 06:52 ------- > I experimented with this a bit after it broke a bit of SDWF. It happens only > if the AA is actually uninitialised - if you've added something to the AA and > then deleted it then it behaves correctly. Added to DStress as http://dstress.kuehne.cn/run/f/foreach_35_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEOWOQ3w+/yD4P9tIRAo6BAJ9QRbbynIICx23H8UY++fHYCrAhbwCdF7Px AegIgXpNCy/EssV8sNYqRVc= =43pG -----END PGP SIGNATURE-----
Comment #4 by bugzilla — 2006-04-11T01:34:57Z
Fixed 0.153
Comment #5 by dlang-bot — 2021-05-27T12:58:15Z
dlang/dlang-bot pull request #271 "Fixes so far" was merged into master: - 284d4c4740655425ef1a98e29a7dd916dbd6f930 by Vladimir Panteleev: Tag Enhancement and Bug in the same pull request Fixes #95. https://github.com/dlang/dlang-bot/pull/271