Unexpected path of execution

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Oct 19 16:31:20 UTC 2021


On Tue, Oct 19, 2021 at 09:20:39AM -0700, Charles Hixson via Digitalmars-d-learn wrote:
> given this code fragment:
> 
>             if    (i < (line.length - 3) )
>             {    writeln ("in c4: i = ", i, ", line.length = ",
> line.length);
>                   add2 (c4, line [i..i+4]);
> I get this result:
> 
> in c4: i = 0, line.length = 2
> core.exception.RangeError at source/freqs.d(32): Range violation
> ----------------
> ??:? _d_arrayboundsp [0x56041325a70d]
> ??:? _Dmain [0x560413233beb]
> 
> Why did this get executed?  The if test was supposed to prevent this.
[...]

Could you post a compilable snippet that exhibits the same problem?  The
incomplete code fragment above doesn't really tell us very much about
what the problem might be.


T

-- 
Life would be easier if I had the source code. -- YHL


More information about the Digitalmars-d-learn mailing list