The attached file that is derived from the spec 2006 benchmark suite fails if
you compile it with minimal optimization and -g.  If I remove the -g option, it
compiles fine.

I initially noticed this on powerpc64-linux-gnu, but it looked like a machine
independent bug, so I tried it on a x86_64-unknown-linux-gnu system.

The debugger trace is:
Current directory is /home/meissner/fsf-build-x86_64/trunk/gcc/
GNU gdb (GDB) Fedora (7.1-34.fc13)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /data/meissner/fsf-build-x86_64/trunk/gcc/cc1...done.
Breakpoint 1 at 0x5bc070: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 878.
Breakpoint 2 at 0x5bce30: file /home/meissner/fsf-src/trunk/gcc/diagnostic.c,
line 819.
Breakpoint 3 at 0x483bd8
Breakpoint 4 at 0x483568
(gdb) r -O -g -quiet foo2.c
Starting program: /data/meissner/fsf-build-x86_64/trunk/gcc/cc1 -O -g -quiet

Program received signal SIGSEGV, Segmentation fault.
0x0000000000bcbb98 in get_symbol_constant_value (sym=0x7ffff06aa640) at
Missing separate debuginfos, use: debuginfo-install glibc-2.12-3.x86_64
libgcc-4.4.4-10.fc13.x86_64 libstdc++-4.4.4-10.fc13.x86_64
(gdb) where
#0  0x0000000000bcbb98 in get_symbol_constant_value (sym=0x7ffff06aa640) at
#1  0x0000000000bcbf5f in maybe_fold_reference (expr=0x7ffff05e7a80, is_lhs=0
'\000') at /home/meissner/fsf-src/trunk/gcc/gimple-fold.c:554
#2  0x0000000000bcf428 in fold_stmt_1 (gsi=0x7fffffffc3f0, inplace=<value
optimized out>) at /home/meissner/fsf-src/trunk/gcc/gimple-fold.c:1559
#3  0x0000000000a00e34 in fold_marked_statements (first=34,
statements=0x132ce20) at /home/meissner/fsf-src/trunk/gcc/tree-inline.c:4115
#4  0x0000000000a086c5 in optimize_inline_calls (fn=0x7ffff0557500) at
#5  0x00000000009dd62f in inline_transform (node=<value optimized out>) at
#6  inline_transform (node=<value optimized out>) at
#7  0x000000000073b619 in execute_one_ipa_transform_pass () at
#8  execute_all_ipa_transforms () at
#9  0x000000000083454d in tree_rest_of_compilation (fndecl=0x7ffff0557500) at
#10 0x00000000009d2326 in cgraph_expand_function (node=0x7ffff0757d70) at
#11 0x00000000009d4d2a in cgraph_expand_all_functions () at
#12 cgraph_optimize () at /home/meissner/fsf-src/trunk/gcc/cgraphunit.c:1804
#13 0x00000000009d528a in cgraph_finalize_compilation_unit () at
#14 0x00000000004adfa4 in c_write_global_declarations () at
#15 0x00000000007dbd5c in compile_file (argc=5, argv=0x7fffffffc978) at
#16 do_compile (argc=5, argv=0x7fffffffc978) at
#17 toplev_main (argc=5, argv=0x7fffffffc978) at
#18 0x0000003db681ec5d in __libc_start_main () from /lib64/
#19 0x0000000000494f19 in _start ()
(gdb) print sym
$1 = (union tree_node *) 0x7ffff06aa640
(gdb) pt
 <var_decl 0x7ffff06aa640 cactuspriv_
    type <record_type 0x7ffff0750e70 asm_written type_0 BLK
        size <integer_cst 0x7ffff0868c30 constant 448>
        unit size <integer_cst 0x7ffff0710b18 constant 56>
        align 64 symtab -260754336 alias set -1 canonical type 0x7ffff0750e70
        fields <field_decl 0x7ffff074ca18 cctk_run_title type <pointer_type
            unsigned DI file foo2.c line 98 col 9
            size <integer_cst 0x7ffff076c7a8 constant 64>
            unit size <integer_cst 0x7ffff076c7d0 constant 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff076c410 constant 0>
            bit offset <integer_cst 0x7ffff076cb18 constant 0> context
<record_type 0x7ffff0750e70> chain <field_decl 0x7ffff074cab0
cctk_timer_output>> context <translation_unit_decl 0x7ffff074b730 D.2979>
        chain <type_decl 0x7ffff074b508 D.2681>>
    used public external common BLK file foo2.c line 109 col 3 size
<integer_cst 0x7ffff0868c30 448> unit size <integer_cst 0x7ffff0710b18 56>
    align 64 chain <function_decl 0x7ffff0745c00 CCTK_StaggerVars>>
(gdb) print varpool_get_node (sym)
$2 = (struct varpool_node *) 0x0
(gdb) quit
A debugging session is active.

        Inferior 1 [process 20829] will be killed.

Quit anyway? (y or n) y

Debugger finished

It fails because get_symbol_constant_value calls varpool_get_node, which in
turns returns a NULL pointer.

           Summary: Segmentation violation when compiling spec source on
                    either x86 or ppc with debugging
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: meissner at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu

Reply via email to