See the timing, testcase is the usual mktime test from autoconf : [~]> gcc -O2 -o mktime mktime.c [~]> time ./mktime zsh: alarm ./mktime ./mktime 32,22s user 27,70s system 99% cpu 1:00,00 total [~]> gcc -o mktime mktime.c [~]> time ./mktime ./mktime 0,04s user 0,03s system 100% cpu 0,067 total [~]> gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc/4.3.0 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include --datadir=/usr/share/gcc/i686-pc-linux-gnu/4.3.0 --mandir=/usr/share/gcc/i686-pc-linux-gnu/4.3.0/man --infodir=/usr/share/gcc/i686-pc-linux-gnu/4.3.0/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include/g++-v3 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-libgcj --disable-libssp --disable-multilib --disable-nls --disable-werror --enable-checking=release --enable-clocale=gnu --enable-__cxa_atexit --enable-languages=c,c++,fortran,objc,obj-c++,treelang --enable-libstdcxx-allocator=new --enable-shared --enable-ssp --enable-threads=posix --enable-version-specific-runtime-libs --without-included-gettext --without-system-libunwind --with-system-zlib --with-pkgversion='Pardus Linux' --with-bugurl=http://bugs.pardus.org.tr Thread model: posix gcc version 4.3.0 20071215 [trunk revision 130952] (Pardus Linux)
Created attachment 14766 [details] testcase
Timings with gcc 3.4.6 : [~]> gcc -o mktime mktime.c [~]> time ./mktime real 0m0.052s user 0m0.021s [~]> gcc -O2 -o mktime mktime.c [~]> time ./mktime real 0m0.032s user 0m0.021s sys 0m0.011s So this is a regression.
Hmm, I think time_t is signed so this is just a case of signed overflow being undefined.
Yes this is invalid, time_t is signed so the following loop is empty: for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2) continue;
I don't believe this is invalid changing time_t_max and time_t_min to unsigned long doesn't fix the problem.
Created attachment 14768 [details] Testcase with unsigned long values