Where's the axe? Can't walk_tree.

John David Anglin dave@hiauly1.hia.nrc.ca
Sat Apr 14 14:20:00 GMT 2001


I have enclosed a patch for review.  It has been bootstrap tested under
i686 linux with PCC_STATIC_STRUCT_RETURN defined in linux.h.  The build
of libstdc++-v3 under vax ultrix goes much further than ever before
but there are still problems:

/xxx/gnu/gcc-3.0/objdir/gcc/xgcc -B/xxx/gnu/gcc-3.0/objdir/gcc/ -nostdinc++ -L/xxx/gnu/gcc-3.0/objdir/vax-dec-ultrix4.3/libstdc++-v3/src -L/xxx/gnu/gcc-3.0/objdir/vax-dec-ultrix4.3/libstdc++-v3/src/.libs -B/usr/local/vax-dec-ultrix4.3/bin/ -B/usr/local/vax-dec-ultrix4.3/lib/ -isystem /usr/local/vax-dec-ultrix4.3/include -nostdinc++ -I../../../../libstdc++-v3/include -I../../../../libstdc++-v3/include/std -I../../../../libstdc++-v3/include/c_std -I../include -I../../../../libstdc++-v3/libsupc++ -I../libio -I../../../../libstdc++-v3/libio -I../../../../libstdc++-v3/libmath -g -O2 -fno-implicit-templates -Wall -Wno-format -W -Wwrite-strings -Winline -fdiagnostics-show-location=once -g -c ../../../../libstdc++-v3/src/misc-inst.cc -o misc-inst.o
../../../../libstdc++-v3/include/bits/basic_string.h: In function
   `std::basic_istream<_CharT, _Traits>&
   std::operator>>(std::basic_istream<_CharT, _Traits>&,
   std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits =
   std::char_traits<char>, _Alloc = std::allocator<char>]':
../../../../libstdc++-v3/src/misc-inst.cc:189:   instantiated from here
../../../../libstdc++-v3/include/bits/basic_string.h:1133: warning: comparison
   between signed and unsigned integer expressions
/usr/tmp/ccsCMPtL.s: Assembler messages:
/usr/tmp/ccsCMPtL.s:45114: Error: Attempt to get value of unresolved symbol __n:V28
/usr/tmp/ccsCMPtL.s:45114: Error: Attempt to get value of unresolved symbol __n:
V28
/usr/tmp/ccsCMPtL.s:45114: Error: Attempt to get value of unresolved symbol
/usr/tmp/ccsCMPtL.s:45114: Error: Attempt to get value of unresolved symbol
make[4]: *** [misc-inst.lo] Error 1

The problem causing the infinite recursion was the call to build_aggr_init
in simplify_aggr_init_exprs_r.  It converted the just built call_expr back
to an expression containing another aggr_init_expr.

> 
> The following error occurs compiling cinst.cc under vax ultrix 4.3:
> 
> /xxx/gnu/gcc-2.97/objdir/gcc/g++ -B/xxx/gnu/gcc-2.97/objdir/gcc/ -nostdinc++ -isystem /xxx/gnu/gcc-2.97/libstdc++ -isystem /xxx/gnu/gcc-2.97/libstdc++/std -isystem /xxx/gnu/gcc-2.97/libstdc++/stl -isystem /xxx/gnu/gcc-2.97/libio -isystem /xxx/gnu/gcc-2.97/objdir/vax-dec-ultrix4.3/libio -L/xxx/gnu/gcc-2.97/objdir/vax-dec-ultrix4.3/libstdc++ -B/usr/local/vax-dec-ultrix4.3/bin/ -B/usr/local/vax-dec-ultrix4.3/lib/ -isystem /usr/local/vax-dec-ultrix4.3/include -c -O3 -fno-implicit-templates -I../../../libstdc++ -I../../../libstdc++/stl -I../libio -I../../../libstdc++/../libio -I../../../libstdc++/../include -I../../../libstdc++/../gcc -nostdinc++  -DF `for N in MAIN ADDCC ADDCF ADDFC SUBCC SUBCF SUBFC MULCC MULCF MULFC DIVCC DIVCF DIVFC PLUS MINUS EQCC EQCF EQFC NECC NECF NEFC ABS ARG POLAR CONJ NORM COS COSH EXP LOG POWCC POWCF POWCI POWFC SIN SINH SQRT; do echo " -D${N}"; done` \
>   ../../../libstdc++/cinst.cc -o fcomplex.o
> ../libio/_G_config.h:85: warning: badly nested C headers from preprocessor
> ../../../libstdc++/cmath:6: warning: badly nested C headers from preprocessor
> g++: Internal error: Illegal instruction (program cc1plus)
> Please submit a full bug report.
> See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
> make[1]: *** [bigstmp-complx] Error 1
> make[1]: Leaving directory `/xxx/gnu/gcc-2.97/objdir/vax-dec-ultrix4.3/libstdc++'
> make: *** [all-target-libstdc++] Error 2
> Wed Nov 29 07:51:59 EST 2000
> 
> The internal error is caused by cc1plus exceeding the maximum stack size.
> It occurs processing the header fcomplex.h for the function
> const complex<float> operator+(const complex<float>&, float).  For some
> reason, the recursive calls to walk the tree lead to infinite recursion:
> 
> (gdb) bt -10
> #18906 0xe9d66 in walk_tree (tp=0x3ffbd4, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, 
>     htab=0x308700, 3180288, 1) at ../../gcc/cp/tree.c:1286
> #18907 0xe9d66 in walk_tree (tp=0x3ffbf0, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, htab=0x308700)
>     at ../../gcc/cp/tree.c:1286
> #18908 0xe9d66 in walk_tree (tp=0x3fd160, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, htab=0x308700)
>     at ../../gcc/cp/tree.c:1286
> #18909 0xe9da3 in walk_tree (tp=0x3fd150, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, htab=0x308700)
>     at ../../gcc/cp/tree.c:1307
> #18910 0xe9d66 in walk_tree (tp=0x3dbb80, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, htab=0x308700)
>     at ../../gcc/cp/tree.c:1286
> #18911 0xed91c in walk_tree_without_duplicates (tp=0x3dbb80, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0)
>     at ../../gcc/cp/tree.c:1444
> #18912 0xe4559 in expand_body (fn=0x3e0000, 4063232)
>     at ../../gcc/cp/semantics.c:2332
> #18913 0xa1c60 in yyparse () at /usr/local/share/bison.simple:2162
> #18914 0x11b41e in compile_file (name=0x7fffc1cd "fcomplex.ii")
>     at ../../gcc/toplev.c:2361
> #18915 0x120802 in main (argc=4, argv=0x7fffc0c0, 2147467476)
>     at ../../gcc/toplev.c:4843
> 
> (gdb) frame 18911
> #18911 0xed91c in walk_tree_without_duplicates (tp=0x3dbb80, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0)
>     at ../../gcc/cp/tree.c:1444
> 1444      result = walk_tree (tp, func, data, htab);
> (gdb) p debug_tree (*tp)
>  <compound_stmt 003fd140 tree_1 tree_2
>     arg 0 <scope_stmt 003fd160 tree_0 tree_1
>         chain <return_stmt 003ffbe0 tree_1
>             arg 0 <init_expr 003ffbc0 type <record_type 00344800 complex<float>>
>                  side-effects arg 0 <result_decl 003fc380>
>                  arg 1 <target_expr 003ff940 type <record_type 00344800 complex<float>>
>                      side-effects addressable arg 0 <var_decl 00400000>
>                      arg 1 <compound_expr 00400bc0 type <record_type 00344800 complex<float>>
>                          side-effects
> 			 arg 0 <stmt_expr 00400ba0 type <record_type 00344800 complex<float>>
>                              side-effects used arg 0 <compound_stmt 004008a0>> arg 1 <var_decl 00400000>>>>
>             chain <scope_stmt 00400800 tree_1>>>>
> $3 = void
> 
> At frame #5, we have
> 
> (gdb) frame 5
> #5  0xe97ca in walk_tree (tp=0xa52854, 
>     func=0xe40ac <simplify_aggr_init_exprs_r>, data=0x0, htab=0x308700)
>     at ../../gcc/cp/tree.c:1251
> 1251      result = (*func) (tp, &walk_subtrees, data);
> (gdb) p debug_tree (*tp)
>  <aggr_init_expr 00a52820
>     type <record_type 00344800 complex<float> needs-constructing type_1 type_5 DI
>         size <integer_cst 002d2c00 constant 64>
>         unit size <integer_cst 002d2c20 constant 8>
>         align 32 symtab 0 alias set -1
>         fields <field_decl 003db380 re type <real_type 002d4600 float>
>             private nonlocal decl_3 SF file ../../../libstdc++/std/fcomplex.h line 51
>             size <integer_cst 002d2c40 constant 32>
>             unit size <integer_cst 002d2c80 constant 4>
>             align 32 offset_align 32
>             offset <integer_cst 002d2ea0 constant 0>
>             bit offset <integer_cst 002d2ec0 constant 0> context <record_type 00344800 complex<float>> arguments <integer_cst 002d2ea0 0> chain <field_decl 003dc800 im>>
>        needs-constructor X() X(constX&) this=(X&) n_parents 0 use_template=2 vtable-needs-writing
>         member-functions <tree_vec 003e9380
>              elt 0 <overload 003cc370>
>              elt 2 <function_decl 003e9280 operator=>
>              elt 3 <function_decl 003d8900 operator+=>
>              elt 4 <function_decl 003d8b80 operator-=>
>              elt 5 <function_decl 003d9a00 operator*=>
>              elt 6 <function_decl 003da880 operator/=>
>              elt 7 <function_decl 003daa80 real>
>              elt 8 <function_decl 003db200 imag>>
>         pointer_to_this <pointer_type 00344880> reference_to_this <reference_type 003d7a00> chain <type_decl 00344900 complex<float>>>
>     side-effects
>     arg 0 <addr_expr 003ff8e0
> 	type <pointer_type 003feb80 type <function_type 003df380>
>             unsigned SI size <integer_cst 002d2c40 32> unit size <integer_cst 002d2c80 4>
>             align 32 symtab 0 alias set -1>
>         readonly
>         arg 0 <function_decl 003fea00 operator+ type <function_type 003df380>
>             readonly used public external inline QI file ../../../libstdc++/std/complext.h line 160
>             frame_size 0 arguments <parm_decl 003fea80 x> initial <block 0036c920>
>             template-info 003ff0e0
>             (mem:QI (symbol_ref:SI ("__pl__H1Zf_RCt7complex1ZX01X01_t7complex1ZX01")) 0)>>
>     arg 1 <tree_list 003ff280
>         value <nop_expr 003ff260 type <reference_type 003d7b00>
>             readonly
>             arg 0 <convert_expr 003ff240 type <pointer_type 003dab80>
>                 readonly arg 0 <parm_decl 003df280 x>>>
>         chain <tree_list 003ff2a0 value <parm_decl 003df300 y>>>
>     arg 2 <var_decl 00a4fb00 type <record_type 00344800 complex<float>>
>         used DI file ../../../libstdc++/std/fcomplex.h line 60 size <integer_cst 002d2c00 64> unit size <integer_cst 002d2c20 8>
>         align 32>>
> $4 = void
> 
> Debugging this is a real maize.  Let me know if anyone has any clues or
> suggestions.
> 

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-04-13  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* semantics.c (simplify_aggr_init_exprs_r): Add DIRECT_BIND to flags
	in call to build_aggr_init to prevent conversion of CALL_EXPR back
	to a AGGR_INIT_EXPR.  This prevents infinite recursion when
	PCC_STATIC_STRUCT_RETURN is defined.  Save flag_access_control
	across call to build_aggr_init.

--- semantics.c.orig	Thu Apr 12 12:35:13 2001
+++ semantics.c	Fri Apr 13 21:27:06 2001
@@ -2237,10 +2237,11 @@
 #ifdef PCC_STATIC_STRUCT_RETURN  
   if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p (type))
     {
-      int old_ac;
+      int old_ac = flag_access_control;
 
       flag_access_control = 0;
-      call_expr = build_aggr_init (slot, call_expr, LOOKUP_ONLYCONVERTING);
+      call_expr = build_aggr_init (slot, call_expr,
+				   DIRECT_BIND | LOOKUP_ONLYCONVERTING);
       flag_access_control = old_ac;
       copy_from_buffer_p = 1;
     }



More information about the Gcc-bugs mailing list