[Issue 16149] foreach_reverse can't handle index variable of type int

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 10 08:24:37 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16149

--- Comment #2 from Acer.Yang <yangacer at gmail.com> ---
(In reply to Ketmar Dark from comment #1)
> ...and, techincally, it shouldn't.
> 
> first case (roughly) does: `int i; while (i < s.length) ...` which is
> perfectly legal. but second does: `int i = s.length;`, which requires
> conversion from `size_t` (of type `ulong` on 64-bit arch) to `int`, which is
> illegal.
> 
> i'd say that first case should be forbidden too, but the seconds case -- in
> my opinion -- doesn't require fixing.

I agree that the first case should be forbidden(since signed/unsigned
comparison is not safe per my eyes).

--


More information about the Digitalmars-d-bugs mailing list