[c++ patch] PR c++/11530

Jan Hubicka jh@suse.cz
Mon Jul 28 17:16:00 GMT 2003


> On Mon, 2003-07-28 at 09:04, Jan Hubicka wrote:
> > > On Sun, 2003-07-27 at 13:36, Jan Hubicka wrote:
> > > > Hi,
> > > > this appars to be another missing mark_used call in C++ frontend.
> > > > 
> > > > Honza
> > > > 
> > > > Sun Jul 27 22:35:09 CEST 2003  Jan Hubicka  <jh@suse.cz>
> > > > 	PR c++/11530
> > > > 	* typeck.c (build_address): Add missing mark_used.
> > > > Index: typeck.c
> > > > ===================================================================
> > > > RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
> > > > retrieving revision 1.483
> > > > diff -c -3 -p -r1.483 typeck.c
> > > > *** typeck.c	19 Jul 2003 16:09:47 -0000	1.483
> > > > --- typeck.c	27 Jul 2003 20:34:40 -0000
> > > > *************** build_address (tree t)
> > > > *** 3804,3809 ****
> > > > --- 3804,3810 ----
> > > >   
> > > >     if (error_operand_p (t) || !cxx_mark_addressable (t))
> > > >       return error_mark_node;
> > > > +   mark_used (t);
> > > >   
> > > >     addr = build1 (ADDR_EXPR, 
> > > >   		 build_pointer_type (TREE_TYPE (t)),
> > > 
> > > This patch is certainly incorrect, since there is no guarantee that T is
> > > a decl.
> > > 
> > > What is the call stack at the point that build_address is called?
> > It comes from the build_unary_operator fromt the same file, if I recall
> > correctly.
> 
> I think we need to look further, then.  In general, mark_used should be
> called when the expression for the function is first parsed.

This is the full backtrace.  What do you think is wrong?
You may look at the testcase I am attaching.  It is fairly simple.

void a (void (*f)())
{
  f();
}

struct RunState
{
  static void runcallback() { }
  static void wait()
  {
    a (runcallback);
  }
};

int main()
{
  RunState::wait();
  return 0;
}

GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
Breakpoint 1 at 0x824150a: file ../../gcc/diagnostic.c, line 1371.
Breakpoint 2 at 0x80498b0
Breakpoint 3 at 0x8049630
(gdb) run ~/tcc.          break build_address
Breakpoint 4 at 0x8159e8e: file ../../gcc/cp/typeck.c, line 3805.
(gdb) run -O2 ~/tcc.C
Starting program: /aux/hubicka/egcs/gcc/build/gcc/cc1plus -O2 ~/tcc.C
Breakpoint 2 at 0x4004add5
Breakpoint 3 at 0x40049b27

Breakpoint 4, build_address (t=0x401c7d80) at ../../gcc/cp/typeck.c:3805
3805	  if (error_operand_p (t) || !cxx_mark_addressable (t))
(gdb) bt
#0  build_address (t=0x401c7d80) at ../../gcc/cp/typeck.c:3805
#1  0x0815bc65 in build_unary_op (code=ADDR_EXPR, xarg=0x401743f0, noconvert=0)
    at ../../gcc/cp/typeck.c:4239
#2  0x08151043 in decay_conversion (exp=0x401743f0)
    at ../../gcc/cp/typeck.c:1530
#3  0x080575eb in convert_like_real (convs=0x401ca500, expr=0x401743f0, 
    fn=0x401c7798, argnum=0, inner=0, issue_conversion_warnings=true)
    at ../../gcc/cp/call.c:4194
#4  0x08058337 in build_over_call (cand=0x4016e398, flags=3)
    at ../../gcc/cp/call.c:4480
#5  0x08052c4d in build_new_function_call (fn=0x401c7798, args=0x401ca4b0)
    at ../../gcc/cp/call.c:2788
#6  0x0818ac98 in finish_call_expr (fn=0x401c7798, args=0x401ca4b0, 
    disallow_virtual=false) at ../../gcc/cp/semantics.c:1648
#7  0x08135230 in cp_parser_postfix_expression (parser=0x401c90c0, 
    address_p=false) at ../../gcc/cp/parser.c:3537
#8  0x08135ca8 in cp_parser_unary_expression (parser=0x401c90c0, 
    address_p=false) at ../../gcc/cp/parser.c:4091
#9  0x08136328 in cp_parser_cast_expression (parser=0x401c90c0, 
    address_p=false) at ../../gcc/cp/parser.c:4515
#10 0x081417d3 in cp_parser_simple_cast_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:13610
#11 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3b40, fn=0x81417c0 <cp_parser_simple_cast_expression>)
    at ../../gcc/cp/parser.c:13128
#12 0x0813634b in cp_parser_pm_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4536
#13 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3b60, fn=0x8136330 <cp_parser_pm_expression>)
    at ../../gcc/cp/parser.c:13128
#14 0x0813636b in cp_parser_multiplicative_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4560
#15 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3b80, 
    fn=0x8136350 <cp_parser_multiplicative_expression>)
    at ../../gcc/cp/parser.c:13128
#16 0x0813638b in cp_parser_additive_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4583
#17 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3b98, fn=0x8136370 <cp_parser_additive_expression>)
    at ../../gcc/cp/parser.c:13128
#18 0x081363ab in cp_parser_shift_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4606
#19 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3bc0, fn=0x8136390 <cp_parser_shift_expression>)
    at ../../gcc/cp/parser.c:13128
#20 0x081363cb in cp_parser_relational_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4641
#21 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3bf8, fn=0x81363b0 <cp_parser_relational_expression>)
    at ../../gcc/cp/parser.c:13128
#22 0x081363eb in cp_parser_equality_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4664
#23 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3c10, fn=0x81363d0 <cp_parser_equality_expression>)
    at ../../gcc/cp/parser.c:13128
#24 0x0813640b in cp_parser_and_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4685
#25 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3c20, fn=0x81363f0 <cp_parser_and_expression>)
    at ../../gcc/cp/parser.c:13128
#26 0x0813642b in cp_parser_exclusive_or_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4706
#27 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3c30, fn=0x8136410 <cp_parser_exclusive_or_expression>)
    at ../../gcc/cp/parser.c:13128
#28 0x0813644b in cp_parser_inclusive_or_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4728
#29 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3c40, fn=0x8136430 <cp_parser_inclusive_or_expression>)
    at ../../gcc/cp/parser.c:13128
#30 0x0813646b in cp_parser_logical_and_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4749
#31 0x08140d0f in cp_parser_binary_expression (parser=0x401c90c0, 
    token_tree_map=0x85c3c50, fn=0x8136450 <cp_parser_logical_and_expression>)
    at ../../gcc/cp/parser.c:13128
#32 0x0813648b in cp_parser_logical_or_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4770
#33 0x08136567 in cp_parser_assignment_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4838
#34 0x0813671f in cp_parser_expression (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:4986
#35 0x08136b57 in cp_parser_expression_statement (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5264
#36 0x081369a3 in cp_parser_statement (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5177
#37 0x08136c37 in cp_parser_statement_seq_opt (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5322
#38 0x08136bcb in cp_parser_compound_statement (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5295
#39 0x0813cff1 in cp_parser_function_body (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:10709
#40 0x0813d022 in cp_parser_ctor_initializer_opt_and_function_body (
    parser=0x401c90c0) at ../../gcc/cp/parser.c:10726
#41 0x08141253 in cp_parser_function_definition_after_declarator (
    parser=0x401c90c0, inline_p=true) at ../../gcc/cp/parser.c:13426
#42 0x08141a63 in cp_parser_late_parsing_for_member (parser=0x401c90c0, 
    member_function=0x401c7e58) at ../../gcc/cp/parser.c:13689
#43 0x0813dafb in cp_parser_class_specifier (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:11178
#44 0x08139d67 in cp_parser_type_specifier (parser=0x401c90c0, 
    flags=CP_PARSER_FLAGS_OPTIONAL, is_friend=false, is_declaration=true, 
    declares_class_or_enum=0xbffff633, is_cv_qualifier=0xbffff632)
    at ../../gcc/cp/parser.c:8094
#45 0x08137bdf in cp_parser_decl_specifier_seq (parser=0x401c90c0, 
    flags=CP_PARSER_FLAGS_OPTIONAL, attributes=0xbffff66c, 
    declares_class_or_enum=0xbffff66b) at ../../gcc/cp/parser.c:6330
#46 0x081378bb in cp_parser_simple_declaration (parser=0x401c90c0, 
    function_definition_allowed_p=true) at ../../gcc/cp/parser.c:6070
#47 0x08137888 in cp_parser_block_declaration (parser=0x401c90c0, 
    statement_p=false) at ../../gcc/cp/parser.c:6030
#48 0x08137735 in cp_parser_declaration (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5950
#49 0x08137560 in cp_parser_declaration_seq_opt (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:5859
#50 0x081334aa in cp_parser_translation_unit (parser=0x401c90c0)
    at ../../gcc/cp/parser.c:2136
#51 0x08142964 in c_parse_file () at ../../gcc/cp/parser.c:14314
#52 0x081e43bc in c_common_parse_file (set_yydebug=0)
    at ../../gcc/c-opts.c:1211
#53 0x084b5788 in compile_file () at ../../gcc/toplev.c:1749
#54 0x084ba54d in do_compile () at ../../gcc/toplev.c:4526
#55 0x084ba5e2 in toplev_main (argc=3, argv=0xbffff854)
    at ../../gcc/toplev.c:4567
#56 0x081e81cf in main (argc=3, argv=0xbffff854) at ../../gcc/main.c:35



More information about the Gcc-patches mailing list