From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2E2983858C30 for ; Tue, 7 Mar 2023 15:00:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E2983858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678201216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nOGJIBbghmdMYVFkPRAxTQJyXmxGbJ6hE0a9ojb2QdU=; b=g3jBRHonFUIQgahsS007PKb0EUD6a0+R9KvIsqYRJn41o0bZ2h/xOrgVvdutey0hsoW7OW AnE6X8UbDm46YVtku39ldTfelTFBT+hL1GJ1j6TYPctubvgJ/I0ybwdm6FxhZOwS+7mjdL TD53zt5owNm4l/uUiuU+EG7RQEn0QuQ= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-6jeGC3V4NlW0fMZVCJFn5w-1; Tue, 07 Mar 2023 10:00:14 -0500 X-MC-Unique: 6jeGC3V4NlW0fMZVCJFn5w-1 Received: by mail-qt1-f198.google.com with SMTP id p7-20020ac84607000000b003b9b6101f65so7256301qtn.11 for ; Tue, 07 Mar 2023 07:00:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678201214; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nOGJIBbghmdMYVFkPRAxTQJyXmxGbJ6hE0a9ojb2QdU=; b=C1Wvk/9+xTo4/fajXjkgjT2aEie9VuT177s+3TZE4IbDJt2yCCfFB6xntusB9I8EuH gOU92WwB6DqihWNGLodT3Qu174HIJNE4ACbxUH2Ca+4jEnRrFXRduuSFwHqVVrsk8Eje YhdoHgEKFnug0374MCzy1cmlMisvqdgU4mgUz4+Dppz8aONNxGdbUACxXjTTRtCvC+In D9rvEm9nIB6E285NthT+wT4TZoQYvETpCAiiauVBuTTzlQlzSQaGxOnw3XZKHpagKk3l NO8RoKHpGuZvp9dhnrU70YNROWrNW+BPhDtO5b5jkcMFdE4rzsHnTb8+1iz3AFbSlz8n sYZw== X-Gm-Message-State: AO0yUKV5Gf67SwXoXomsnhvk6+RAqs6so6BCy+UT015TXnbMMSX1xP0+ 2qU1/kE/54/ZsAbuF94IGDB4XsOi0eO0D1rPEIlt/DGZoA2vEgUL1NxWj/39VF7jrH2Wk3elFCA 4GPUjU96laZgHyHt/Jg== X-Received: by 2002:a05:622a:118a:b0:3bf:c3f2:82ff with SMTP id m10-20020a05622a118a00b003bfc3f282ffmr25354574qtk.7.1678201213679; Tue, 07 Mar 2023 07:00:13 -0800 (PST) X-Google-Smtp-Source: AK7set/TRiDbsNnYt7hO7gx8p6NZJuSQRUrHYTMFDkd07uxelUFLU3EwIyRW8acSKwl+fgDyXtrXJA== X-Received: by 2002:a05:622a:118a:b0:3bf:c3f2:82ff with SMTP id m10-20020a05622a118a00b003bfc3f282ffmr25354493qtk.7.1678201213245; Tue, 07 Mar 2023 07:00:13 -0800 (PST) Received: from [192.168.1.108] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id v25-20020ac873d9000000b003c033b23a9asm2518137qtp.12.2023.03.07.07.00.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Mar 2023 07:00:12 -0800 (PST) Message-ID: Date: Tue, 7 Mar 2023 10:00:10 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] c++: Fix up ICE in emit_support_tinfo_1 [PR109042] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/7/23 04:07, Jakub Jelinek wrote: > Hi! > > In my recent rtti.cc change I assumed when emitting the support tinfos > that the tinfos for the fundamental types haven't been created yet. > Normally (in libsupc++.a (fundamental_type_info.o)) that is the case, > but as can be seen on the testcase, one can violate it by using typeid > etc. in the same TU and do it before ~__fundamental_type_info () > definition. > > The following patch fixes that by popping from unemitted_tinfo_decls > only in the normal case when it is there, and treating non-NULL > DECL_INITIAL on a tinfo node as indication that emit_tinfo_decl has > processed it already. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2023-03-07 Jakub Jelinek > > PR c++/109042 > * rtti.cc (emit_support_tinfo_1): Don't assert that last > unemitted_tinfo_decls element is tinfo, instead pop from it only in > that case. > * decl2.cc (c_parse_final_cleanups): Don't call emit_tinfo_decl > for unemitted_tinfO_decls which have already non-NULL DECL_INITIAL. > > * g++.dg/rtti/pr109042.C: New test. > > --- gcc/cp/rtti.cc.jj 2023-03-03 00:34:52.028567946 +0100 > +++ gcc/cp/rtti.cc 2023-03-06 19:06:27.433307136 +0100 > @@ -1581,10 +1581,10 @@ emit_support_tinfo_1 (tree bltn) > /* Emit it right away if not emitted already. */ > if (DECL_INITIAL (tinfo) == NULL_TREE) > { > - gcc_assert (unemitted_tinfo_decls->last () == tinfo); > bool ok = emit_tinfo_decl (tinfo); > gcc_assert (ok); > - unemitted_tinfo_decls->pop (); > + if (unemitted_tinfo_decls->last () == tinfo) > + unemitted_tinfo_decls->pop (); So if it's not last we'll leave it in the vec, even though it is no longer unemitted, and let c_parse_final_cleanups deal with removing it? That could use a comment. OK with that change. > } > } > } > --- gcc/cp/decl2.cc.jj 2023-01-18 16:11:47.053213397 +0100 > +++ gcc/cp/decl2.cc 2023-03-06 19:07:16.830582984 +0100 > @@ -4982,7 +4982,7 @@ c_parse_final_cleanups (void) > get emitted. */ > for (i = unemitted_tinfo_decls->length (); > unemitted_tinfo_decls->iterate (--i, &t);) > - if (emit_tinfo_decl (t)) > + if (DECL_INITIAL (t) || emit_tinfo_decl (t)) > { > reconsider = true; > unemitted_tinfo_decls->unordered_remove (i); > --- gcc/testsuite/g++.dg/rtti/pr109042.C.jj 2023-03-06 19:11:06.995208812 +0100 > +++ gcc/testsuite/g++.dg/rtti/pr109042.C 2023-03-06 19:10:59.117324298 +0100 > @@ -0,0 +1,20 @@ > +// PR c++/109042 > +// { dg-do compile } > + > +namespace std { class type_info {}; } > + > +std::type_info > +foo () > +{ > + return typeid (void); > +} > + > +namespace __cxxabiv1 { > + struct __fundamental_type_info { > + virtual ~__fundamental_type_info (); > + }; > + > + __fundamental_type_info::~__fundamental_type_info () > + { > + } > +} > > Jakub >