cc1plus crashes with a sigsegv. The crash does occur with -O2, not with -Os or -O1. The crash does not occur if I do not use an anonymous namespace for the functions ReadPIB7400, ReadPIB7420, AddAdapterAndReferencedAdapters and GenerateTrafficForPhyRate (by commenting out the lines #73452, #73458, #74520 and #74616).
Attachment missing.
Created attachment 28144 [details] preprocessed file as written by the sigsegv handler
Created attachment 28145 [details] preprocessed file as written by the sigsegv handler Just saw a second sigsegv. This might be related to the bug (including same project files), but it might also be another bug. This compilation succeeds with -O0 and -O1, it crashes with -O3, -O2 and -Os. In this case there is no anonymous namespace involved.
gcc-4.7 and 4.8 are also affected. markus@x4 tmp % cat test.ii template < typename T > T h2le (T) { T a; unsigned short &b = a; short c = 0; unsigned char (&d)[2] = reinterpret_cast < unsigned char (&)[2] > (c); unsigned char (&e)[2] = reinterpret_cast < unsigned char (&)[2] > (b); e[0] = d[0]; return a; } void bar () { h2le ((unsigned short) 0); } markus@x4 tmp % gdb /var/tmp/foo/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0/g++ Reading symbols from /var/tmp/foo/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0/g++...done. (gdb) run -c -O2 -std=c++0x test.ii Starting program: /var/tmp/foo/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0/g++ -c -O2 -std=c++0x test.ii warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 [New process 18282] process 18282 is executing new program: /var/tmp/foo/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0/cc1plus Program received signal SIGSEGV, Segmentation fault. [Switching to process 18282] 0x00000000008b5803 in disqualify_base_of_expr(tree_node*, char const*) () at ../../gcc/gcc/tree-sra.c:987 987 ../../gcc/gcc/tree-sra.c: No such file or directory. (gdb) bt #0 0x00000000008b5803 in disqualify_base_of_expr(tree_node*, char const*) () at ../../gcc/gcc/tree-sra.c:987 #1 0x00000000008b6eb5 in build_access_from_expr_1(tree_node*, gimple_statement_d*, bool) () at ../../gcc/gcc/tree-sra.c:1025 #2 0x00000000008b74ab in scan_function() () at ../../gcc/gcc/tree-sra.c:1119 #3 0x00000000008bb622 in ipa_early_sra() () at ../../gcc/gcc/tree-sra.c:4814 #4 0x00000000007ca012 in execute_one_pass(opt_pass*) () at ../../gcc/gcc/passes.c:2158 #5 0x00000000007ca385 in execute_pass_list(opt_pass*) () at ../../gcc/gcc/passes.c:2213 #6 0x00000000007ca397 in execute_pass_list(opt_pass*) () at ../../gcc/gcc/passes.c:2214 #7 0x00000000007c95fd in do_per_function_toporder(void (*)(void*), void*) () at ../../gcc/gcc/passes.c:1702 #8 0x00000000007ca7ec in execute_ipa_pass_list(opt_pass*) () at ../../gcc/gcc/passes.c:2527 #9 0x000000000064f758 in compile() () #10 0x000000000064fb15 in finalize_compilation_unit() () #11 0x0000000000528a57 in cp_write_global_declarations() () at ../../gcc/gcc/cp/decl2.c:4024 #12 0x000000000085a565 in compile_file() () #13 0x000000000085bd5a in toplev_main(int, char**) () #14 0x00007ffff74ef755 in __libc_start_main () from /lib/libc.so.6 #15 0x00000000004c8249 in _start ()
(In reply to comment #3) > Created attachment 28145 [details] > preprocessed file as written by the sigsegv handler > > Just saw a second sigsegv. This might be related to the bug (including same > project files), but it might also be another bug. > This compilation succeeds with -O0 and -O1, it crashes with -O3, -O2 and -Os. > In this case there is no anonymous namespace involved. It's the same issue.
The following patch fixes the issue for me: diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index aafaa15..2bb92e9 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -984,7 +984,8 @@ static void disqualify_base_of_expr (tree t, const char *reason) { t = get_base_address (t); - if (sra_mode == SRA_MODE_EARLY_IPA + if (t + && sra_mode == SRA_MODE_EARLY_IPA && TREE_CODE (t) == MEM_REF) t = get_ssa_base_param (TREE_OPERAND (t, 0));
Author: rguenth Date: Mon Sep 10 09:48:28 2012 New Revision: 191130 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191130 Log: 2012-09-07 Markus Trippelsdorf <markus@trippelsdorf.de> PR middle-end/54515 * tree-sra.c (disqualify_base_of_expr): Check for possible NULL_TREE returned by get_base_address() * g++.dg/tree-ssa/pr54515.C: new testcase Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/tree-ssa/pr54515.C Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree-sra.c
Author: rguenth Date: Mon Sep 10 09:50:02 2012 New Revision: 191131 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191131 Log: 2012-09-10 Markus Trippelsdorf <markus@trippelsdorf.de> PR middle-end/54515 * tree-sra.c (disqualify_base_of_expr): Check for possible NULL_TREE returned by get_base_address() * g++.dg/tree-ssa/pr54515.C: new testcase Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/tree-ssa/pr54515.C Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/testsuite/ChangeLog branches/gcc-4_6-branch/gcc/tree-sra.c
Testing sth different for trunk.
Author: rguenth Date: Tue Sep 11 08:32:29 2012 New Revision: 191174 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191174 Log: 2012-09-11 Richard Guenther <rguenther@suse.de> PR middle-end/54515 * gimple.c (get_base_address): Do not return NULL_TREE apart from for WITH_SIZE_EXPR. * gimple-fold.c (canonicalize_constructor_val): Do not call get_base_address when not necessary. * g++.dg/tree-ssa/pr54515.C: New testcase. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/pr54515.C Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-fold.c trunk/gcc/gimple.c trunk/gcc/testsuite/ChangeLog
Fixed.