public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
@ 2020-03-25 13:09 marxin at gcc dot gnu.org
2020-03-25 13:09 ` [Bug debug/94326] " marxin at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-25 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
Bug ID: 94326
Summary: g++: error: pack.ii: ‘-fcompare-debug’ failure
(length)
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
This one is very old (at least GCC 4.8.0):
$ cat pack.ii
template <typename = int> class A {
const int &m_fn1() { return 0; }
public:
template <typename _Kt> void m_fn2(_Kt) { m_fn1(); }
};
class B {
A<> _M_t;
public:
template <typename _Kt> auto m_fn3(_Kt p1) -> decltype(_M_t.m_fn2(p1)) {
_M_t.m_fn2(p1);
}
};
struct C {};
void operator<(C, int) {
B a;
a.m_fn3(C{});
}
$ g++ pack.ii -c -fcompare-debug -std=c++11
pack.ii: In instantiation of ‘const int& A< <template-parameter-1-1> >::m_fn1()
[with <template-parameter-1-1> = int]’:
pack.ii:5:45: required from ‘void A< <template-parameter-1-1> >::m_fn2(_Kt)
[with _Kt = C; <template-parameter-1-1> = int]’
pack.ii:12:15: required from ‘decltype
(((B*)this)->B::_M_t.A<>::m_fn2<_Kt>(p1)) B::m_fn3(_Kt) [with _Kt = C; decltype
(((B*)this)->B::_M_t.A<>::m_fn2<_Kt>(p1)) = void]’
pack.ii:18:14: required from here
pack.ii:2:31: warning: returning reference to temporary [-Wreturn-local-addr]
2 | const int &m_fn1() { return 0; }
| ^
g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug debug/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
@ 2020-03-25 13:09 ` marxin at gcc dot gnu.org
2020-03-25 15:27 ` marxin at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-25 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug debug/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
2020-03-25 13:09 ` [Bug debug/94326] " marxin at gcc dot gnu.org
@ 2020-03-25 15:27 ` marxin at gcc dot gnu.org
2020-03-26 12:30 ` [Bug c++/94326] " jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-25 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-03-25
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
2020-03-25 13:09 ` [Bug debug/94326] " marxin at gcc dot gnu.org
2020-03-25 15:27 ` marxin at gcc dot gnu.org
@ 2020-03-26 12:30 ` jakub at gcc dot gnu.org
2020-03-26 12:31 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-26 12:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|debug |c++
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Indeed, I think this started failing with
r0-114389-g4b6aaa996e0d8f5abac818315b6f77cb3596db98
before which it has been rejected with sorry message.
The bug isn't debug related in this case, but -w is affecting generated code.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2020-03-26 12:30 ` [Bug c++/94326] " jakub at gcc dot gnu.org
@ 2020-03-26 12:31 ` jakub at gcc dot gnu.org
2020-03-26 13:58 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-26 12:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
$ rm -f pr94326.C.*; ./cc1plus -quiet -std=c++11 pr94326.C -Wreturn-local-addr
-da; grep REG_EH_REGION pr94326.C.*
pr94326.C: In instantiation of ‘const int& A< <template-parameter-1-1>
>::m_fn1() [with <template-parameter-1-1> = int]’:
pr94326.C:5:45: required from ‘void A< <template-parameter-1-1> >::m_fn2(_Kt)
[with _Kt = C; <template-parameter-1-1> = int]’
pr94326.C:12:15: required from ‘decltype
(((B*)this)->B::_M_t.A<>::m_fn2<_Kt>(p1)) B::m_fn3(_Kt) [with _Kt = C; decltype
(((B*)this)->B::_M_t.A<>::m_fn2<_Kt>(p1)) = void]’
pr94326.C:18:14: required from here
pr94326.C:2:31: warning: returning reference to temporary [-Wreturn-local-addr]
2 | const int &m_fn1() { return 0; }
| ^
$ rm -f pr94326.C.*; ./cc1plus -quiet -std=c++11 pr94326.C
-Wno-return-local-addr -da; grep REG_EH_REGION pr94326.C.*
pr94326.C.236r.expand: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.236r.expand: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.237r.vregs: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.238r.into_cfglayout: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.239r.jump: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.239r.jump: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.251r.reginfo: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.274r.outof_cfglayout: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.275r.split1: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.277r.dfinit: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.278r.mode_sw: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.279r.asmcons: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.284r.ira: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.285r.reload: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.292r.pro_and_epilogue: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.295r.jump2: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.306r.split4: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.307r.stack: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.308r.alignments: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.310r.mach: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.311r.barriers: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.316r.shorten: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.317r.nothrow: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.318r.dwarf2: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.319r.final: (expr_list:REG_EH_REGION (const_int 0 [0])
pr94326.C.320r.dfinish: (expr_list:REG_EH_REGION (const_int 0 [0])
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2020-03-26 12:31 ` jakub at gcc dot gnu.org
@ 2020-03-26 13:58 ` jakub at gcc dot gnu.org
2020-03-26 14:05 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-26 13:58 UTC (permalink / raw)
To: gcc-bugs
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?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2020-03-26 13:58 ` jakub at gcc dot gnu.org
@ 2020-03-26 14:05 ` jakub at gcc dot gnu.org
2020-03-27 9:05 ` cvs-commit at gcc dot gnu.org
2020-03-27 20:19 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-26 14:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/cp/call.c.jj 2020-03-25 08:05:07.153731580 +0100
+++ gcc/cp/call.c 2020-03-26 15:03:42.432909693 +0100
@@ -333,11 +333,14 @@ set_flags_from_callee (tree call)
&& internal_fn_flags (CALL_EXPR_IFN (call)) & ECF_NOTHROW)
nothrow = true;
- if (!nothrow && at_function_scope_p () && cfun && cp_function_chain)
- cp_function_chain->can_throw = 1;
+ if (cfun && cp_function_chain && !cp_unevaluated_operand)
+ {
+ if (!nothrow && at_function_scope_p ())
+ cp_function_chain->can_throw = 1;
- if (decl && TREE_THIS_VOLATILE (decl) && cfun && cp_function_chain)
- current_function_returns_abnormally = 1;
+ if (decl && TREE_THIS_VOLATILE (decl))
+ current_function_returns_abnormally = 1;
+ }
TREE_NOTHROW (call) = nothrow;
}
seems to work, but not sure if that is what we want.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2020-03-26 14:05 ` jakub at gcc dot gnu.org
@ 2020-03-27 9:05 ` cvs-commit at gcc dot gnu.org
2020-03-27 20:19 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-03-27 9:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:2eea00c518d5a72d0bdbc810ae675e7ad5fee414
commit r10-7411-g2eea00c518d5a72d0bdbc810ae675e7ad5fee414
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Mar 27 10:04:31 2020 +0100
c++: Avoid calls in non-evaluated contexts affect whether function can or
can't throw [PR94326]
The following testcase FAILs -fcompare-debug, because if we emit a
-Wreturn-local-addr warning, we tsubst decltype in order to print the
warning and as that function could throw, set_flags_from_callee during that
sets cp_function_chain->can_throw and later on we don't set TREE_NOTHROW
on foo. While with -w or -Wno-return-local-addr, tsubst isn't called
during
the warning_at, cp_function_chain->can_throw is kept clear and TREE_NOTHROW
is set on foo.
It isn't just a matter of the warning though, in
int foo ();
int bar () { return sizeof (foo ()); }
int baz () { return sizeof (int); }
I don't really see why we should mark only baz as TREE_NOTHROW and not bar
too, when neither can really throw.
2020-03-27 Jakub Jelinek <jakub@redhat.com>
PR c++/94326
* call.c (set_flags_from_callee): Don't update
cp_function_chain->can_throw or current_function_returns_abnormally
if cp_unevaluated_operand.
* g++.dg/other/pr94326.C: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/94326] g++: error: pack.ii: ‘-fcompare-debug’ failure (length)
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
` (6 preceding siblings ...)
2020-03-27 9:05 ` cvs-commit at gcc dot gnu.org
@ 2020-03-27 20:19 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-27 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94326
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10+.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-03-27 20:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 13:09 [Bug debug/94326] New: g++: error: pack.ii: ‘-fcompare-debug’ failure (length) marxin at gcc dot gnu.org
2020-03-25 13:09 ` [Bug debug/94326] " marxin at gcc dot gnu.org
2020-03-25 15:27 ` marxin at gcc dot gnu.org
2020-03-26 12:30 ` [Bug c++/94326] " jakub at gcc dot gnu.org
2020-03-26 12:31 ` jakub at gcc dot gnu.org
2020-03-26 13:58 ` jakub at gcc dot gnu.org
2020-03-26 14:05 ` jakub at gcc dot gnu.org
2020-03-27 9:05 ` cvs-commit at gcc dot gnu.org
2020-03-27 20:19 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).