Created attachment 30157 [details] backtrace The following code crashes GCC (gcc-4.8.0 -O2): typedef void (*done)(void* arg); struct t { done func; void* arg; }; static void test_func() __attribute__((optimize("O0"))); static void test_func(struct t* a) { a->func(a->arg); } Program received signal SIGSEGV, Segmentation fault. walk_aliased_vdefs_1 (ref=ref@entry=0x7fffffffda70, vdef=0x0, walker=0x6f5d90 <mark_modified(ao_ref*, tree, void*)>, data=0x7fffffffda5f, visited=0x7fffffffda28, cnt=0) at /mnt/work/oktet/transas/sources/4.8/gcc/gcc/tree-ssa-alias.c:2196 2196 gimple def_stmt = SSA_NAME_DEF_STMT (vdef); Backtrace from gdb attached. Reproducable with custom GCC build and gentoo 4.8. No error in 4.7.
Reproducable with gcc-4.8.1. Using built-in specs. COLLECT_GCC=gcc-4.8.1 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /mnt/work/tmp/portage/sys-devel/gcc-4.8.1/work/gcc-4.8.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-cloog --disable-isl-version-check --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.1/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,go,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.1 p1.0, pie-0.5.6' Thread model: posix gcc version 4.8.1 (Gentoo 4.8.1 p1.0, pie-0.5.6) $ gcc-4.8.1 -O3 -c no-optimize.c no-optimize.c: In function ‘test_func’: no-optimize.c:7:1: internal compiler error: Segmentation fault } ^
More simplified test variant: struct t { void (*func)(void*); }; void test_func(struct t* a) __attribute__((optimize("O0"))); void test_func(struct t* a) { a->func(0); } P.S. If you compile this as C++ code, no segmentation fault would occure.
I'll take a look.
I have submitted a fix for the 4.8 branch here: http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00663.html and for the current trunk here: http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00666.html
Author: jamborm Date: Mon Jun 24 12:51:43 2013 New Revision: 200369 URL: http://gcc.gnu.org/viewcvs?rev=200369&root=gcc&view=rev Log: 2013-06-24 Martin Jambor <mjambor@suse.cz> PR tree-optimization/57358 * ipa-prop.c (ipa_func_spec_opts_forbid_analysis_p): New function. (ipa_compute_jump_functions_for_edge): Bail out if it returns true. (ipa_analyze_params_uses): Generate pessimistic info when true. testsuite * gcc.dg/ipa/pr57358.c: New test. Added: trunk/gcc/testsuite/gcc.dg/ipa/pr57358.c Modified: trunk/gcc/ChangeLog trunk/gcc/ipa-prop.c trunk/gcc/testsuite/ChangeLog
Author: jamborm Date: Mon Jun 24 12:57:52 2013 New Revision: 200370 URL: http://gcc.gnu.org/viewcvs?rev=200370&root=gcc&view=rev Log: 2013-06-24 Martin Jambor <mjambor@suse.cz> PR tree-optimization/57358 * ipa-prop.c (parm_ref_data_preserved_p): Always return true when not optimizing. testsuite/ * gcc.dg/ipa/pr57358.c: New test. Added: branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/ipa/pr57358.c Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/ipa-prop.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog