Bug 10221 – foreach(char c; 0..256) doesn't work even though the upper bound is 255
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-31T16:32:00Z
Last change time
2014-02-08T09:22:18Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
thelastmammoth
Comments
Comment #0 by thelastmammoth — 2013-05-31T16:32:55Z
foreach(char c; 0..256) doesn't work even though the upper bound is 255:
Error: cannot implicitly convert expression (256) of type int to char
Maybe instead disallow: foreach(char c; 0..257) ?
Is that a bug, or how would we achieve iterating over all chars without resorting to :
foreach(c_; 0..256){
char c=c_.to!char;
}
Comment #1 by andrej.mitrovich — 2013-05-31T18:39:10Z