$ time g++-snapshot -O -c list1.ii real 0m3.617s user 0m3.515s sys 0m0.043s $ time g++-3.4 -O -c list1.ii
real 0m0.068s user 0m0.028s sys 0m0.007s $ g++-snapshot -v Using built-in specs. Configured with: ../src/configure -v --enable-languages=c,c++,java,objc,ada --prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --enable-nls --enable-threads=posix --without-included-gettext --disable-werror --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk i486-linux-gnu Thread model: posix gcc version 4.0.0 20050110 (experimental) $ cat list1.ii # 1 "list1.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "list1.cpp" template<class T> class Pointer { typedef Pointer<T> point; T *ptr; public: Pointer() : ptr(0) { } Pointer(T *x) : ptr(x) { if(ptr) ptr->inc(); } ~Pointer() { if(ptr) ptr->dec(); ptr=0; } T *operator->() const { return ptr; } T &operator*() const { return *ptr; } bool null() const { return ptr == 0; } void exchange(Pointer &x) { T *t = x.ptr; x.ptr = ptr; ptr = t; } }; class ListNode { public: mutable int count; Pointer<ListNode> next; void unhook(Pointer<ListNode> *p) { while(!(*p).null() && (*p)->count == 1) { Pointer<ListNode> t; t.exchange((*p)->next); t.exchange(*p); } } public: ~ListNode() { unhook(&next); } void inc() const { ++count; } void dec() const { if(--count <= 0) delete this; } public: ListNode(const int &d) : count(0), next() { } }; void test(ListNode p) { p.unhook(&p.next); } -- Summary: 50 fold compile time increase between gcc-3,4 and gcc- 4,0 on included code Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: phil at fsel dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19445