Compile this trivial program --------- #include <iostream> #include <fstream>
int main() { std::ifstream fin("t3.cpp"); } --------- with g++ -g -O2 -Wall -pthread t3.cpp Running this program dumps core. Leaving out the option -pthread it does not abort and works o.k. Root cause seems to be that the std::ifstream class has different size with and without -pthread (i.e. -DTHREAD_SAFE) since definition of ifstream member std::__c_lock == __gthread_mutex_t is different with and without -pthread. This is an AIX only symptom. __c_lock is an int without threads and posix_lock with threads. Since there is only one libstdc++ for both with and without threads weird things will happen. -- diagnosis program -- #include <fstream> #include <iostream> int main() { printf( "%ld\n",sizeof( std::ifstream)); printf(" %ld\n", sizeof( __gthread_mutex_t)); } ---------------- Output with -pthread 296 52 --- without 248 4 ------------ I would propose to compile gcc code always with THREAD_SAFE alway on. -- Summary: ifstream broken Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: o dot flebbe at science-computing dot de GCC build triplet: powerpc-ibm-aix5.3.0.0 GCC host triplet: powerpc-ibm-aix5.3.0.0 GCC target triplet: powerpc-ibm-aix5.3.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42349