From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id D8A443853570 for ; Wed, 8 Jun 2022 07:02:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8A443853570 Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 3227966799; Wed, 8 Jun 2022 03:02:18 -0400 (EDT) Message-ID: <875a5f84da00d9ade01a444a4ead4b5d4dfd9c58.camel@xry111.site> Subject: Re: Incorrect replacement of TYPE_METHODS with TYPE_FIELDS causing segfault. From: Xi Ruoyao To: Zopolis0 , gcc-help Date: Wed, 08 Jun 2022 15:02:16 +0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, LIKELY_SPAM_FROM, PDS_OTHER_BAD_TLD, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 07:02:22 -0000 On Wed, 2022-06-08 at 14:47 +1000, Zopolis0 via Gcc-help wrote: /* snip */ > java/lang/Object.java: internal compiler error: tree check: expected > function_decl, have field_decl in layout_class_method, at java/class.cc:2= 627 >=20 > I believe that this error is due to the following incorrect code at line > 2589 at gcc/java/class.cc: > =C2=A0 for (tree method_decl =3D TYPE_FIELDS (this_class); >=20 > Before it was removed, this line was: > =C2=A0 for (method_decl =3D TYPE_METHODS (this_class); >=20 > But I have since modified it ( > https://github.com/Zopolis4/gcj/commit/1f38bc896a704290ca0b742c60c60a88d5= e1fb07#diff-bf49cdc948b20b9f25afd3fbb36922a10e979a55ff9600b3b51d0ec54175b75= 2L2592) > in accordance with 5aaa8fb40681ee66282d73dab8c8eccbf5ee0518 >=20 > Given that this was incorrect, what would be the correct way to replace > this instance of TYPE_METHODS? Were all my replacements of TYPE_METHODS i= n > gcc/java/class.cc wrong? 5aaa8fb is not a simple replacement. For example: /* If there are user-defined methods, they are deemed non-trivial. */ - for (tmp =3D TYPE_METHODS (type); tmp; tmp =3D TREE_CHAIN (tmp)) - if (!DECL_ARTIFICIAL (tmp)) + for (tree fld =3D TYPE_FIELDS (type); fld; fld =3D DECL_CHAIN (fld)) + if (TREE_CODE (TREE_TYPE (fld)) =3D=3D METHOD_TYPE && !DECL_ARTIFICIAL= (fld)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ return true; I think you need to check if the field is really a method like this. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University