简体   繁体   English

C ++ builder 2010中奇怪的“随机”内部编译器错误

[英]Strange “random” internal compiler error in C++ builder 2010

I have some code that puts a bunch of TNotifyEvents in a vector . 我有一些代码将一堆TNotifyEvents放在一个向量中

std::vector<TNotifyEvent> m_availableCallbacks;

This is a member of the main form of the application. 这是应用程序主要形式的成员。 In the forms constructor it's filled with the events. 在表单构造函数中,它充满了事件。

m_availableCallbacks.push_back(ReadoutLastValue);
m_availableCallbacks.push_back(ReadoutCurrentDay);
m_availableCallbacks.push_back(ReadoutLastDay);
m_availableCallbacks.push_back(Readout7Days);
m_availableCallbacks.push_back(Readout1Month);
m_availableCallbacks.push_back(ReadoutChooseTimeSpan);
m_availableCallbacks.push_back(ReadoutAllData);

This vector is then iterated and used to create a popup menu and assign notification events to the elements in that popup menu. 然后迭代此向量并用于创建弹出菜单并将通知事件分配给该弹出菜单中的元素。

Compiling this locally poses no problem. 在本地编译这个没有问题。 When I compiled it on the build server (running TeamCity 6.5 ) I get an internal compiler error on the row equal to the second push_back call. 当我在构建服务器(运行TeamCity 6.5 )上编译它时,我得到的行等于第二个push_back调用的内部编译器错误。

I tried disabling smart cache precompiled headers locally on the build agent by editing the cbproj files. 我尝试通过编辑cbproj文件在构建代理上本地禁用智能缓存预编译头 This produced a successfull build. 这产生了成功的构建。 So I removed the directive to use smart cache precompiled headers from all cbproj files and committed the changes. 所以我删除了指令,使用来自所有cbproj文件的智能缓存预编译头文件并提交了更改。 I told TeamCity to do a Clean Checkout and once again I got the same internal compiler error, at the same place. 我告诉TeamCity做一个Clean Checkout ,我又在同一个地方得到了相同的内部编译器错误。 The strange thing is that running a new compilation after the failed one succeeds, so this feels extremely random. 奇怪的是,在失败的一个成功之后运行一个新的编译,所以这感觉非常随机。

What is going on? 到底是怎么回事? I'm used to passing around function pointers (crated by myself) in other C++ compilers just fine. 我习惯于在其他C ++编译器中传递函数指针(由我自己创建)。 Is the internal handling of the TNotifyEvents broken or is the compiler just unstable and easily broken? TNotifyEvents的内部处理是否已损坏或编译器是否不稳定且容易损坏?

Looking at other code taking TNotifyEvents they don't work on references or pointers, so I didn't try that. 看看其他采用TNotifyEvents的代码,它们不能用于引用或指针,所以我没有尝试过。 And since the code (when it compiles) works as intended that does not seem to be the problem. 并且因为代码(当它编译时)按预期工作似乎不是问题。

Update: 更新:

I can add that the log for TeamCity says that the FrontEnd.cpp file (which contains this code), is skipped when I re-run the compilation and it succeeds. 我可以补充一点, TeamCity的日志说当重新运行编译时它会跳过 FrontEnd.cpp文件(包含此代码),并且成功。

[10:04:37]: [MakeObjs] CallTarget
[10:04:37]:   [CallTarget] _CppDepCheck
[10:04:44]:     [_CppDepCheck] MessageMap
[10:04:44]:       [MessageMap] Skipping: ..., FrontEnd.cpp, ...

And for that to even work the compilation must have succeeded when the internal compiler error occurred. 为此,即使工作,编译必须在发生内部编译器错误时成功。 How could it otherwise skip compiling the file and still have it magically appear and be used in a compiled form? 它怎么可能会跳过编译文件仍然神奇地出现并以编译形式使用? :) :)

Update2 UPDATE2

After investigation I can confirm that this ONLY occurs when compiling in release mode. 经过调查,我可以确认只有在发布模式下进行编译时才会发生这种情况。 In release it happens even on my local machine in the IDE. 在发布中,它甚至发生在IDE中的本地计算机上。 I have tried fiddling with the settings like 我试过摆弄像这样的设置

  • Disable all optimizations 禁用所有优化
  • Generate fastest code possible 尽可能生成最快的代码
  • External type files 外部类型文件
  • and so on 等等

cleaning the build between each try. 清理每次尝试之间的构建。 But the ICE does not go away. 但ICE并没有消失。 I did however manage to make it complain about another spot in another file. 然而,我确实设法让它抱怨另一个文件中的另一个地方。 Setting the settings back to how they were before does NOT make the error go back to the FrontEnd.cpp file. 将设置恢复为之前的设置不会使错误返回到FrontEnd.cpp文件。 This compiler feels kinda shaky :) 这个编译器感觉有点不稳定:)

In fact I started getting ICE's all over the code and had to restart the IDE to be able to compile anything at all. 事实上,我开始在代码中获得ICE,并且必须重新启动IDE以便能够编译任何内容。

This seems to be connected with the std::vector . 这似乎与std :: vector有关 Not sure if it's broken by itself or the way it's handled by bcc is the problem. 不确定它是单独打破还是由bcc处理的方式是问题所在。 But switching to an C-style array as a test instead made the ICE go away and it now works fine in both debug and release mode. 但是切换到C风格的数组作为测试使得ICE消失了,现在它在调试和发布模式下都能正常工作。

TNotifyEvent m_availableCallbacks[7];

I wanted to avoid this since adding new events to the vector would involve almost only one line of code. 我想避免这种情况,因为向向量添加新事件几乎只涉及一行代码。 Now there will be a bit more to remember to change as well. 现在还会有更多要记住改变。 But, better to have the application compile. 但是,最好让应用程序编译。

If I'm wrong thinking that this is a bug in BCC, please correct me so I can go back to using a vector asap :)... Otherwise I hope Embarcadero fixes this asap. 如果我错误地认为这是BCC中的一个错误,请纠正我,以便我可以尽快回到使用向量:)...否则我希望Embarcadero尽快解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM