这里是一个我不认为应该发生一个很奇怪的事情:__最终在C++ Builder 2010中丢失范围?
UnicodeString test = "abc";
try
{
try
{
int a = 123;
return a; // This seems to produce a problem with "test" variable scope
}
catch (Exception &e)
{
// Some exception handler here
}
}
__finally
{
// At this point the "test" variable should still be in scope???
test = "xyz"; // PROBLEM here - test is NULL instead of "abc"! Why?
}
如果我在try-catch
块测试变量仍然被定义中删除return a;
。在上面的构造之后,UnicodeString似乎超出了范围,是否有特定的原因?这是C++ Builder 2010的错误吗?我明白,从函数返回返回,但它应该仍然保留变量范围在__finally
块不应该吗?
这也发生在C++ Builder XE5 FWIW上。 – 2014-11-21 20:42:15
昨天在Embarcadero论坛上讨论了这个相同的问题,在那里我提供了一个编译器正在做什么的分析:[为什么UnicodeString在这个例子中失去了范围?](https://forums.embarcadero.com/thread.jspa?线程ID = 110377)。 – 2014-11-21 23:48:38
堆栈展开一直是bcc32中的越野车;例如[此错误](http://stackoverflow.com/a/27117266/1505939)已出现在驴的年份,并仍然存在 – 2014-11-27 02:51:59