October 19, 2021 Re: Unexpected path of execution | ||||
---|---|---|---|---|
| ||||
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@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 |
Copyright © 1999-2021 by the D Language Foundation