Bug 16712 - [4.0 regression] Segmentation fault when accessing const array
Summary: [4.0 regression] Segmentation fault when accessing const array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.0.0
: P1 critical
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-07-26 09:22 UTC by Gábor Lóki
Modified: 2004-09-13 17:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-07-26 17:46:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gábor Lóki 2004-07-26 09:22:07 UTC
With the following c source (foo.i) I have segmentation fault:
typedef struct
{
  char n[129];
} A;

const A C = {
  0,
  0
};

extern const A *const B;

void bar(const char *);

void foo ()
{
  bar (B->n);
}

const A *const B = &C;

Command line:
*gcc -c -O2 -o foo.i foo.c

Output:
foo.i: In function `foo':
foo.i:16: internal compiler error: Segmentation fault
Comment 1 Wolfgang Bangerth 2004-07-26 13:35:32 UTC
I can't seem to reproduce this on my x86 linux box with a snapshot from 
2004-07-21. What is your version? And do you mean that you reproduced 
this bug on all the platforms you listed, i.e. 
  arm-unknown-elf  i386-unknown-elf m68k-unknown-elf mips-unknown- 
 
W. 
Comment 2 Gábor Lóki 2004-07-26 13:40:51 UTC
(In reply to comment #1)
> I can't seem to reproduce this on my x86 linux box with a snapshot from 
> 2004-07-21. What is your version? And do you mean that you reproduced 
> this bug on all the platforms you listed, i.e. 
>   arm-unknown-elf  i386-unknown-elf m68k-unknown-elf mips-unknown- 
Sorry, I forgot to write down the following:

Last known to work: 3.5.0 (2004-07-22 12:00:00 UTC)

First known to fail: 3.5.0 (2004-07-23 12:00:00 UTC)
Last known to fail: 3.5.0 (2004-07-25 12:00:00 UTC)

Comment 3 Andrew Pinski 2004-07-26 13:54:15 UTC
Confirmed, here is the backtrace (I compiled with c++ for some reason but it does not matter):
#0  note_addressable (var=Variable "var" is not available.
) at /home/gates/pinskia/src/gnu/gcc/src/gcc/tree-ssa-operands.c:1434
#1  0x081e1259 in add_stmt_operand (var_p=0x4004f1ac, stmt=0x4004f18c, flags=0, 
prev_vops=0x0)
    at /home/gates/pinskia/src/gnu/gcc/src/gcc/tree-ssa-operands.c:1303
#2  0x081e1b37 in get_expr_operands (stmt=0x4004f18c, expr_p=0x4004f1ac, flags=0, 
prev_vops=0xbffebe70)
    at /home/gates/pinskia/src/gnu/gcc/src/gcc/tree-ssa-operands.c:859
#3  0x081e3789 in get_stmt_operands (stmt=0x4004f18c) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/tree-ssa-operands.c:758
#4  0x0819c970 in mark_new_vars_to_rename (stmt=0x4004f18c, vars_to_rename=0x869a090) at /
home/gates/pinskia/src/gnu/gcc/src/gcc/tree-dfa.c:1051
#5  0x081d12d0 in tree_ssa_ccp () at /home/gates/pinskia/src/gnu/gcc/src/gcc/tree-ssa-ccp.c:435
#6  0x081a6132 in execute_pass_list (pass=0x85f1900) at /home/gates/pinskia/src/gnu/gcc/src/gcc/
tree-optimize.c:446
#7  0x081a6145 in execute_pass_list (pass=0x85f1700) at /home/gates/pinskia/src/gnu/gcc/src/gcc/
tree-optimize.c:472
#8  0x081a6332 in tree_rest_of_compilation (fndecl=0x4010715c, nested_p=0 '\0') at /home/gates/
pinskia/src/gnu/gcc/src/gcc/tree-optimize.c:547
#9  0x08128e88 in expand_body (fn=0x4010715c) at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/
semantics.c:2889
#10 0x084af668 in cgraph_expand_function (node=0x401076cc) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/cgraphunit.c:797
#11 0x084b10bb in cgraph_optimize () at /home/gates/pinskia/src/gnu/gcc/src/gcc/cgraphunit.c:
1669
#12 0x080d4c5c in finish_file () at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/decl2.c:2877
#13 0x0817d1fa in c_common_parse_file (set_yydebug=0) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/c-opts.c:1087
#14 0x0845dbde in toplev_main (argc=0, argv=0xbffec2a4) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/toplev.c:981
#15 0x420174d9 in __libc_start_main () from /lib/i686/libc.so.6
#16 0x08049b31 in _start ()
Comment 4 Diego Novillo 2004-07-26 13:58:54 UTC
May be related to a similar failure that echristo found last week.  Eric, does
your fix address this problem?


Diego.
Comment 5 Eric Christopher 2004-07-26 17:46:03 UTC
Yeah. My patch fixes it. I'll take this until I can commit.

Thanks.
Comment 6 Eric Christopher 2004-07-27 00:20:42 UTC
Fixed with:

2004-07-26  Eric Christopher  <echristo@redhat.com>

	* tree-dfa.c (add_referenced_var): Register initializers of global
	variables.