www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10221] New: foreach(char c; 0..256) doesn't work even though the upper bound is 255

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10221

           Summary: foreach(char c; 0..256) doesn't work even though the
                    upper bound is 255
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com


--- Comment #0 from thelastmammoth gmail.com 2013-05-31 16:32:55 PDT ---
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;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10221


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-05-31
18:39:10 PDT ---
This is similar to what I've ran into 2 years ago:

http://www.digitalmars.com/d/archives/digitalmars/D/learn/Foreach_with_byte_problems_24997.html

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 31 2013