Hi, one of a number of symptoms of an otherwise unrelated HSA bug I've been debugging today is gcc crashing or hanging in the C++ pretty printer when attempting to emit a warning because dump_decl() ended up in an infinite recursion calling itself on the DECL_ABSTRACT_ORIGIN of the decl it was looking at, which was however the same thing. (It was set to itself on purpose in set_decl_origin_self as a part of final pass, the decl was being printed because it was itself an abstract origin of another one).
If someone ever faces a similar problem, the following (untested) patch might save them a bit of time. I have eventually decided not to make it a checking-only assert because it is on a cold path and because at release-build optimization levels, the tail-call is optimized to a jump and thus an infinite loop if the described situation happens, and I suppose an informative ICE is better tan that even for users. What do you think? Would it be reasonable for trunk even now or should I queue it for the next stage1? Thanks, Martin gcc/cp/ 2016-11-28 Martin Jambor <mjam...@suse.cz> * error.c (dump_decl): Add an assert that DECL_ABSTRACT_ORIGIN is not the decl itself. --- gcc/cp/error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7bf07c3..1f2ae1a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1217,7 +1217,10 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) if (! DECL_LANG_SPECIFIC (t)) { if (DECL_ABSTRACT_ORIGIN (t)) - dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags); + { + gcc_assert (DECL_ABSTRACT_ORIGIN (t) != t); + dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags); + } else pp_string (pp, M_("<built-in>")); } -- 2.10.2