[Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 26 13:58:42 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And the reason for the differences is that with -Wno-return-local-addr (or -w
etc.) m_fn1 is marked TREE_NOTHROW (fndecl) in finish_function, while with
-Wreturn-local-addr (and without -w) it is not.
The difference is in cp_function_chain->can_throw , which set not set in the no
warning case, and is set in:
#0  set_flags_from_callee (call=<call_expr 0x7fffea958580>) at
../../gcc/cp/call.c:324
#1  0x0000000000966d3b in build_call_a (function=<call_expr 0x7fffea958580>,
n=2, argarray=0x7fffffffb1e0) at ../../gcc/cp/call.c:365
#2  0x000000000098936f in build_cxx_call (fn=<addr_expr 0x7fffea956f60>,
nargs=2, argarray=0x7fffffffb1e0, complain=128, orig_fndecl=<tree 0x0>)
    at ../../gcc/cp/call.c:9578
#3  0x00000000009877cc in build_over_call (cand=0x3763930, flags=3, complain=0)
at ../../gcc/cp/call.c:9082
#4  0x000000000098c868 in build_new_method_call_1 (instance=<component_ref
0x7fffea949b70>, fns=<overload 0x7fffea936c20>, 
    args=0x7fffffffb860 = {...}, conversion_path=<tree_binfo 0x7fffea93e5a0>,
flags=1, fn_p=0x0, complain=128) at ../../gcc/cp/call.c:10335
#5  0x000000000098cd56 in build_new_method_call (instance=<component_ref
0x7fffea949b70>, fns=<baselink 0x7fffea949ba0>, 
    args=0x7fffffffb860 = {...}, conversion_path=<tree 0x0>, flags=1, fn_p=0x0,
complain=128) at ../../gcc/cp/call.c:10410
#6  0x0000000000c41d6f in tsubst_copy_and_build (t=<call_expr 0x7fffea801188>,
args=<tree_vec 0x7fffea956360>, complain=128, in_decl=<tree 0x0>, 
    function_p=false, integral_constant_expression_p=false) at
../../gcc/cp/pt.c:19812
#7  0x0000000000c2ae69 in tsubst (t=<decltype_type 0x7fffea94f1f8>,
args=<tree_vec 0x7fffea956360>, complain=0, in_decl=<tree 0x0>)
    at ../../gcc/cp/pt.c:15746
#8  0x0000000000ac831c in dump_template_bindings (pp=0x34be940
<actual_pretty_printer>, parms=<tree 0x0>, args=<tree_vec 0x7fffea956360>, 
    typenames=0x7fffea950a28 = {...}) at ../../gcc/cp/error.c:414
#9  0x0000000000ace590 in dump_substitution (pp=0x34be940
<actual_pretty_printer>, t=<template_decl 0x7fffea81e980 m_fn3>, 
    template_parms=<tree_list 0x7fffea935e38>, template_args=<tree_vec
0x7fffea956360>, flags=132) at ../../gcc/cp/error.c:1560
#10 0x0000000000ad0138 in dump_function_decl (pp=0x34be940
<actual_pretty_printer>, t=<template_decl 0x7fffea81e980 m_fn3>, flags=132)
    at ../../gcc/cp/error.c:1718
#11 0x0000000000acd485 in dump_decl (pp=0x34be940 <actual_pretty_printer>,
t=<function_decl 0x7fffea95a700 m_fn3>, flags=132)
    at ../../gcc/cp/error.c:1290
#12 0x0000000000ad6ba8 in decl_to_string (decl=<function_decl 0x7fffea95a700
m_fn3>, verbose=1) at ../../gcc/cp/error.c:3092
#13 0x0000000000ada974 in cp_printer (pp=0x370bbb0, text=0x7fffffffc550,
spec=0x3721f62 "D", precision=0, wide=false, set_locus=false, 
    verbose=true, quoted=0x7fffffffc19f, buffer_ptr=0x3721d70) at
../../gcc/cp/error.c:4260
#14 0x00000000026f5fe2 in pp_format (pp=0x370bbb0, text=0x7fffffffc550) at
../../gcc/pretty-print.c:1458
#15 0x00000000026f63b2 in pp_format_verbatim (pp=0x370bbb0,
text=0x7fffffffc550) at ../../gcc/pretty-print.c:1519
#16 0x00000000026f6c1d in pp_verbatim (pp=0x370bbb0, msg=0x2813680 "required
from %q#D\n") at ../../gcc/pretty-print.c:1773
#17 0x0000000000ad8b73 in print_instantiation_partial_context_line
(context=0x36bc320 <global_diagnostic_context>, t=0x7fffea956440, 
    loc=2147483653, recursive_p=false) at ../../gcc/cp/error.c:3537
#18 0x0000000000ad8e6d in print_instantiation_partial_context
(context=0x36bc320 <global_diagnostic_context>, t0=0x7fffea936860,
loc=2147483653)
    at ../../gcc/cp/error.c:3625
#19 0x0000000000ad89fb in print_instantiation_full_context (context=0x36bc320
<global_diagnostic_context>) at ../../gcc/cp/error.c:3505
#20 0x0000000000ad8eec in maybe_print_instantiation_context (context=0x36bc320
<global_diagnostic_context>) at ../../gcc/cp/error.c:3642
#21 0x0000000000ad74c6 in cp_diagnostic_starter (context=0x36bc320
<global_diagnostic_context>, diagnostic=0x7fffffffc880)
    at ../../gcc/cp/error.c:3341
#22 0x00000000026cfced in diagnostic_report_diagnostic (context=0x36bc320
<global_diagnostic_context>, diagnostic=0x7fffffffc880)
    at ../../gcc/diagnostic.c:1160
#23 0x00000000026d02f2 in diagnostic_impl (richloc=0x7fffffffc8f0,
metadata=0x0, opt=635, gmsgid=0x284c5f8 "returning reference to temporary", 
    ap=0x7fffffffc9a0, kind=DK_WARNING) at ../../gcc/diagnostic.c:1309
#24 0x00000000026d0b70 in warning_at (location=247168, opt=635,
gmsgid=0x284c5f8 "returning reference to temporary")

i.e. when the warning is being emitted.
The call in question is
A<>::m_fn2<C> (&((struct B *) this)->_M_t, TARGET_EXPR <D.2226, p1>

So, shall set_flags_from_callee be setting cp_function_chain->can_throw (or
other flags) even in cp_unevaluated_operand ?  Or shouldn't tsubst or whatever
else sets cp_unevaluated_operand?  Something else?


More information about the Gcc-bugs mailing list