Summary: | [5 Regression] ICE on valid code on x86_64-linux-gnu: tree check: expected tree_binfo, have error_mark in add_candidates, at cp/call.c:5283 | ||
---|---|---|---|
Product: | gcc | Reporter: | Zhendong Su <su> |
Component: | c++ | Assignee: | Patrick Palka <ppalka> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jakub, paolo, webrown.cpp |
Priority: | P2 | Keywords: | ice-checking, ice-on-valid-code |
Version: | 6.0 | ||
Target Milestone: | 6.0 | ||
Host: | Target: | ||
Build: | Known to work: | 4.7.4, 6.1.0 | |
Known to fail: | 4.8.5, 5.0, 6.0 | Last reconfirmed: | 2016-03-13 00:00:00 |
Description
Zhendong Su
2016-03-12 01:36:39 UTC
Confirmed, it ICEs with checking turned on. Note this might be invalid code as what GCC is iceing on is an error_mark node. (In reply to Andrew Pinski from comment #1) > Confirmed, it ICEs with checking turned on. > > Note this might be invalid code as what GCC is iceing on is an error_mark > node. Andrew, this should be valid code. Also see below: $ g++-5.3 -Wall -Wextra -pedantic -c small.cpp $ clang++ -Weverything -pedantic -c small.cpp $ Works on the 4.7 branch. This patch makes us compile the testcase and also passes dg.exp testsuite. But my understanding of BASELINK stuff is too weak to gauge whether this is reasonable approach. --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8125,6 +8125,10 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, /* Dismantle the baselink to collect all the information we need. */ if (!conversion_path) conversion_path = BASELINK_BINFO (fns); + + if (conversion_path == error_mark_node) + return error_mark_node; + access_binfo = BASELINK_ACCESS_BINFO (fns); binfo = BASELINK_BINFO (fns); optype = BASELINK_OPTYPE (fns); Thanks a lot Marek. The patch makes sense to me, I would recommend fully regression testing it and sending it to the mailing list. That would suppress the ICE but in turn it would make us silently generate wrong code since the call to D::f() won't be emitted. adjust_result_of_qualified_name_lookup() is responsible for clobbering the BASELINK_BINFO of the function. This seems to work: --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1751,9 +1751,11 @@ adjust_result_of_qualified_name_lookup (tree decl, if (base && base != error_mark_node) { BASELINK_ACCESS_BINFO (decl) = base; - BASELINK_BINFO (decl) + tree decl_binfo = lookup_base (base, BINFO_TYPE (BASELINK_BINFO (decl)), ba_unique, NULL, tf_none); + if (decl_binfo && decl_binfo != error_mark_node) + BASELINK_BINFO (decl) = decl_binfo; } } I'll post the above patch. I see... Author: ppalka Date: Fri Mar 18 01:26:50 2016 New Revision: 234317 URL: https://gcc.gnu.org/viewcvs?rev=234317&root=gcc&view=rev Log: Fix PR c++/70205 (ICE on valid call to qualified static member function) gcc/cp/ChangeLog: PR c++/70205 * search.c (adjust_result_of_qualified_name_lookup): Don't update the BASELINK_BINFO of DECL if the second call to lookup_base fails. gcc/testsuite/ChangeLog: PR c++/70205 * g++.dg/lookup/pr70205.C: New test. Added: trunk/gcc/testsuite/g++.dg/lookup/pr70205.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/search.c trunk/gcc/testsuite/ChangeLog Fixed on GCC 6 so far. GCC 4.9 branch is being closed GCC 5 branch has been closed, should be fixed in GCC 6 and later. |