The following very simple testcase causes a hang when compiled with certain flags:
int main (int argc, char **argv) { char v = !**argv; if (**argv != v) **argv = argc; if (**argv) **argv = argc; return 0; } The following command lines cause gcc to hang: $ gcc -O2 -ftracer foo.c $ gcc -O -fcse-follow-jumps -frerun-cse-after-loop -ftracer foo.c I could not find a command line that causes a hang without -O (I tried the docs and the "options enabled" output of -v -Q; I haven't tried going through the gcc sources). When run with -dy, the last few lines of output are: Next token is 125 ('}' [}]) Shifting token 125 ('}'), Entering state 540 Reducing via rule 447 (line 1970), -> poplevel state stack now 0 2 40 144 223 314 423 502 593 559 278 379 463 540 Entering state 625 Reducing via rule 459 (line 2046), pushlevel maybe_label_decls compstmt_contents_nonempty '}' poplevel -> compstmt_nostart state stack now 0 2 40 144 223 314 423 502 593 559 Entering state 650 Reducing via rule 463 (line 2076), compstmt_start compstmt_nostart -> compstmt state stack now 0 2 40 144 223 314 423 502 593 Entering state 586 Reducing via rule 455 (line 2034), compstmt -> compstmt_or_error state stack now 0 2 40 144 223 314 423 502 593 Entering state 695 Reducing via rule 21 (line 375), declspecs_ts setspecs declarator @3 old_style_parm_decls save_location @4 compstmt_or_error -> fndef When run with -da, foo.c.15.tracer is written and foo.c.18.cse2 is zero-length. I assume this means it is hanging during the second CSE pass or subsequent jump optimization. This is my gcc -v: Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.3/specs Configured with: /var/tmp/portage/gcc-3.4.3.20050110/work/gcc-3.4.3/configure --enable-version-specific-runtime-libs --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.4.3 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.4.3/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include/g++-v3 --host=i686-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-shared --enable-threads=posix --disable-multilib --disable-libgcj --enable-languages=c,c++,f77 Thread model: posix gcc version 3.4.3 20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0, pie-8.7.7) System type is Gentoo Linux 2005.0, glibc 2.3.4.20041102, kernel 2.6.10-nitro4, Athlon XP. The source file produces no warnings with -Wall. The preprocessed output of the source file is the same as the original (with # lines at the start and tabs converted to spaces). -- Summary: CSE hang on very simple code with -O2 -ftracer Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: normal Priority: P2 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ed at catmur dot co dot uk CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19767