开发者

What's the cause of this Access Violation when concatenating strings in D2007?

I have a procedure that accepts 2 string parameters, one of them has a default value. Inside the procedure, I want to concatenate one and the other and some literals to form one larger string开发者_JAVA技巧. Somehow, I'm getting an AV... any ideas?

code is something like this

{$WRITEABLECONST ON}
constructor MyClass.Create(s1: string; s2: string = GlobalConstant);
var s3: string;
begin
    ....
    if (s2 = '') then s2 := GlobalConstant + ' (' + s1 + ')';      // AV here
    ....
end;

If I assign GlobalConstant + ' (' + s1 + ') to s3, then assign s3 to s2 the AV disappears. Why? What is wrong with writing to the string parameter directly?


Something else in your code is wrong, indirectly resulting in an Access Violation in that location (corruption). Use FastMM with FullDebugMode on to figure out what it is, and how to solve it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜