The GetTextOrDefault functions take "const AnsiString" as an argument, meaning in C++Builder a temporary AnsiString is constructed out of whatever parameter is passed. However, previous versions of Builder are buggy when handling temporaries. This code:

I tried it with the express version of Turbo C++, and the sequence is the correct one: construct, call, delete. However, using Builder4 with the bcc32 5.5.1 from the free commandline tools produces the potentially AVing code. Also if AnsiString is replaced with std::string.

seems fine: first twice { construction of parameter-AnsiString and result-AnsiString, call to GetTextOrDefault }, then the MessageBox, then destruction of all 4 AnsiStrings. And it's without delete[] too.