C++ 11 Threads, Error Pure virtual function called

安稳与你 提交于 2019-12-05 05:17:45

This is a bug in either libstdc++ or Clang, depending on who you ask. It should work if you are using a version of Clang released after October 2013. What do you see when you run g++ --version?

As a workaround, you could try using this command line instead. I don't guarantee that it would work; please post a comment with your results.

g++ -pthread -std=c++11 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4} thread1.cpp

Here's the bug report:

http://llvm.org/bugs/show_bug.cgi?id=12730

And here's the official fix to the Clang driver:

https://llvm.org/viewvc/llvm-project?view=revision&revision=191707

I don't know if this was also previously a bug in the GCC driver, and/or whether it's been fixed.

Ran into the same problem on a Raspberry Pi 2 Model B with an ARM Cortex-A7. Compiled with g++-4.7, turned out the culprit was a compiler flag:

-march=armv7-a

Although clang had a related issue, this is entirely a gcc bug now recorded at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62100

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!