http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53895
Bug #: 53895 Summary: [4.7.2/4.8 Regression][lto] symbol 'std::__once_callable' used as both __thread and non-__thread Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincenzo.innoce...@cern.ch I'm sure was working with 4.7.1 works with gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) this is ok c++ thread.cpp -pthread -std=gnu++0x -O2 this is not c++ thread.cpp -pthread -std=gnu++0x -O2 -flto /afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libstdc++.so: symbol 'std::__once_call' used as both __thread and non-__thread /afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: /tmp/innocent/ccd0XlxC.o: previous definition here /afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../lib64/libstdc++.so: symbol 'std::__once_callable' used as both __thread and non-__thread /afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: /tmp/innocent/ccd0XlxC.o: previous definition here collect2: error: ld returned 1 exit status ld -v GNU gold (GNU Binutils 2.22.52.20120515) 1.11 gcc version 4.7.2 20120629 (prerelease) [gcc-4_7-branch revision 189081] (GCC) gcc version 4.8.0 20120623 (experimental) [trunk revision 188906] (GCC) gcc version 4.8.0 20120708 (experimental) [trunk revision 189362] (GCC) cat thread.cpp include <iostream> #include <sstream> #include <vector> #include <thread> #include <mutex> #include <future> #include <atomic> #include <functional> #include <algorithm> typedef std::thread Thread; typedef std::vector<std::thread> ThreadGroup; typedef std::mutex Mutex; typedef std::unique_lock<std::mutex> Guard; typedef std::condition_variable Condition; long long threadId() { std::stringstream ss; ss << std::this_thread::get_id(); long long id; ss >> id; return id; } namespace global { // control cout.... Mutex coutLock; } int main() { return 0; }