[swift-users] function advancedBy() bugs
zh ao
owenzx at gmail.com
Tue May 17 21:14:23 CDT 2016
I just make a clearer example.
do {
var str = "abcdefg"
var str1 = str + "hijklmn"
var range = str.startIndex..<str1.endIndex
range.startIndex = range.startIndex.advancedBy(10)
//fatal error: cannot increment endIndex
}
It seams that range.startIndex internally contains a fault
endIndex(str.endIndex, it should be its own endIndex, range.endIndex),
which leads the issue.
Zhaoxin
On Wed, May 18, 2016 at 12:02 AM, Dmitri Gribenko <gribozavr at gmail.com>
wrote:
> On Tue, May 17, 2016 at 5:46 AM, zh ao via swift-users
> <swift-users at swift.org> wrote:
> > It seams that I encountered bugs in function advancedBy().
> >
> > do {
> > var str = "abcdefg"
> > var range = str.startIndex..<str.endIndex // 0..<7
> > str += "hijklmn"
> > range.endIndex = str.endIndex // 0..<14
> > let index = range.startIndex.advancedBy(10)
> > //fatal error: cannot increment endIndex
> > }
>
> Hi,
>
> Thank you for the report. To me, this issue looks the same as
> https://bugs.swift.org/browse/SR-1487.
>
> Dmitri
>
> --
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160518/7a7a9f30/attachment.html>
More information about the swift-users
mailing list