optimization/1735: g++ crash in expand_inline_function with optimization

snyder@fnal.gov snyder@fnal.gov
Sun Apr 1 00:00:00 GMT 2001


>Number:         1735
>Category:       optimization
>Synopsis:       g++ crash in expand_inline_function with optimization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 22 14:46:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        2.97 20010122 (experimental)
>Organization:
>Environment:
System: Linux karma 2.2.16-22 #1 Tue Aug 22 16:49:06 EDT 2000 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../egcs/configure --prefix=/usr/local/egcs --enable-threads=posix
>Description:

g++ crashes on the following code when -O3 is used.

>How-To-Repeat:

----------------------------------------
template <class T>
struct A
{
  A ();
};

template <class T>
A<T>::A ()
{
}


template <class T>
struct B
{
  A<int> begin ();
};


template <class T>
A<int>
B<T>::begin ()
{
  return A<int> ();
}


void func ()
{
  A<int> iter;
}

template class B<int>;
template class A<int>;
----------------------------------------


$ ./cc1plus -O3 x2.cc
 A<T>::A() A<int> B<T>::begin() void func() void func() A<T>::A() [with T = int] A<T>::A() [with T = int] A<T>::A() [with T = int] A<T>::A() [with T = int] A<T>::A() [with T = int] A<int> B<T>::begin() [with T = int] A<int> B<T>::begin() [with T = int]
x2.cc:33:   instantiated from here
x2.cc:24: Internal error: Segmentation fault.
Please submit a full bug report.
 See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.


Here's where it's crashing:

Program received signal SIGSEGV, Segmentation fault.
0x822f8d9 in expand_inline_function (fndecl=0x4019d478, parms=0x401a21e0, 
    target=0x0, ignore=1, type=0x4019a7b8, structure_value_addr=0x0)
    at ../../egcs/gcc/integrate.c:963
963       else if (GET_CODE (loc) == MEM)
(gdb) where
#0  0x822f8d9 in expand_inline_function (fndecl=0x4019d478, parms=0x401a21e0, 
    target=0x0, ignore=1, type=0x4019a7b8, structure_value_addr=0x0)
    at ../../egcs/gcc/integrate.c:963
#1  0x81bbf00 in try_to_integrate (fndecl=0x4019d478, actparms=0x401a21e0, 
    target=0x0, ignore=1, type=0x4019a7b8, structure_value_addr=0x0)
    at ../../egcs/gcc/calls.c:1809
#2  0x81bc5d0 in expand_call (exp=0x4019ea40, target=0x0, ignore=1)
    at ../../egcs/gcc/calls.c:2291
#3  0x81aab95 in expand_expr (exp=0x4019ea40, target=0x0, tmode=VOIDmode, 
    modifier=EXPAND_NORMAL) at ../../egcs/gcc/expr.c:7259
#4  0x81a1fe9 in store_expr (exp=0x4019ea60, target=0x401a10c0, want_value=0)
    at ../../egcs/gcc/expr.c:3903
#5  0x81a8d3a in expand_expr (exp=0x4019e980, target=0x401a10c0, tmode=QImode, 
    modifier=EXPAND_NORMAL) at ../../egcs/gcc/expr.c:8321
#6  0x81a1b63 in store_expr (exp=0x4019e980, target=0x401a10c0, want_value=0)
    at ../../egcs/gcc/expr.c:4036
#7  0x81a086f in expand_assignment (to=0x401a0c30, from=0x4019e980, 
    want_value=0, suggest_reg=1) at ../../egcs/gcc/expr.c:3860
#8  0x81a8b63 in expand_expr (exp=0x4019ea00, target=0x0, tmode=VOIDmode, 
    modifier=EXPAND_NORMAL) at ../../egcs/gcc/expr.c:8335
#9  0x8191af6 in expand_return (retval=0x4019ea00)
    at ../../egcs/gcc/stmt.c:3123
#10 0x8147281 in genrtl_return_stmt (stmt=0x401a21a4)
    at ../../egcs/gcc/c-semantics.c:536
#11 0x8147f39 in expand_stmt (t=0x401a2014) at ../../egcs/gcc/c-semantics.c:786
#12 0x8147fa9 in expand_stmt (t=0x401a2000) at ../../egcs/gcc/c-semantics.c:814
#13 0x811ff8e in expand_body (fn=0x4019d958)
    at ../../egcs/gcc/cp/semantics.c:2422
#14 0x809ff35 in instantiate_decl (d=0x4019d958, defer_ok=0)
    at ../../egcs/gcc/cp/pt.c:9984
#15 0x80a086b in instantiate_pending_templates ()
    at ../../egcs/gcc/cp/pt.c:10057
#16 0x80c236c in finish_file () at ../../egcs/gcc/cp/decl2.c:3629
#17 0x80d6915 in yyparse_1 () at /usr/lib/bison.simple:441
#18 0x814e9fd in compile_file (name=0x8473ee3 "x2.cc")
    at ../../egcs/gcc/toplev.c:2379
#19 0x815285c in main (argc=3, argv=0xbffff914) at ../../egcs/gcc/toplev.c:4879
#20 0x4003dfd1 in __libc_start_main (main=0x8152380 <main>, argc=3, 
    ubp_av=0xbffff914, init=0x8049198 <_init>, fini=0x834eb9c <_fini>, 
    rtld_fini=0x4000e254 <_dl_fini>, stack_end=0xbffff90c)
    at ../sysdeps/generic/libc-start.c:118
(gdb) p loc
$1 = 0x0



>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-prs mailing list