vector crash

zjh fqbqrr at 163.com
Thu Jan 18 03:07:13 UTC 2024


```d
import dparse.ast;
import dparse.lexer;
import dparse.parser : parseModule;
import dparse.rollback_allocator : RollbackAllocator;
import core.stdcpp.vector;
import core.stdcpp.string;

Vector!string d=[];toV(a,d);
print(d);//3
foreach(e;d){
     string b=d[i];
     string m=readText(b);ff(m,b);
}

void ff(string B,string s)
{
     LexerConfig config;
     auto cache = StringCache(StringCache.defaultBucketCount);
     auto tokens = getTokensForParser(B, config, &cache);
     RollbackAllocator rba;
     auto m = parseModule(tokens,s, &rba);
     auto v= new V();
     v.visit(m);v.out(s);
}

```
Why can `b` still affect `e` here? Isn't `b` copied?
here foreach crashes.



More information about the Digitalmars-d-learn mailing list