Bug 14996 – only(EnumMembers!T) eats all my memory when T : string

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-09-01T13:12:00Z
Last change time
2015-09-07T16:23:25Z
Keywords
ice, pull
Assigned to
nobody
Creator
ryan

Attachments

IDFilenameSummaryContent-TypeSize
1546scratch.dcompiling with dmd should consume excessive memorytext/x-dsrc581

Comments

Comment #0 by ryan — 2015-09-01T13:12:13Z
Created attachment 1546 compiling with dmd should consume excessive memory I am trying to return a range of all members in a named enum using only(EnumMembers!MyEnum). This works fine, unless MyEnum uses string as a backing value and has more than one element, in which case it eats all 8GB of my memory and crashes DMD. Test file is attached and pasted below: --- import std.range : only; import std.traits : EnumMembers; enum Bad : string { confirm = "confirm", cancel = "cancel" , rotateL = "rotateL", rotateR = "rotateR", turbo = "turbo" , menu = "menu" , } enum Fine { confirm, cancel , rotatel, rotater, turbo , menu , } enum AlsoFine : string { confirm = "confirm", } auto allButtons() { //return only(EnumMembers!Fine); // compiles just fine //return only(EnumMembers!AlsoFine); // compiles just fine return only(EnumMembers!Bad); // eats all my memory (8GB) } void main() { } ---
Comment #1 by ryan — 2015-09-01T13:19:04Z
Also fails: with(Button) return only(confirm, cancel, rotateL, rotateR, turbo, menu);
Comment #2 by k.hara.pg — 2015-09-06T13:08:58Z
Reduced test case: enum Bad : string { confirm = "confirm", } struct OnlyResult { Bad[1] data; } void main() {}
Comment #3 by k.hara.pg — 2015-09-06T13:10:07Z
Comment #4 by github-bugzilla — 2015-09-07T16:23:24Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2070e8e1386ad03d1d77d7beff910bfca31a8aad fix Issue 14996 - only(EnumMembers!T) eats all my memory when T : string https://github.com/D-Programming-Language/dmd/commit/21e644ee74d83c64869c60830b96547736765c73 Merge pull request #5046 from 9rnsr/fix14996 Issue 14996 - only(EnumMembers!T) eats all my memory when T : string