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 933DF3858D39 for ; Wed, 28 Feb 2024 21:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 933DF3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 933DF3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709156993; cv=none; b=FZgY1ovKwKVfekJ8lGanNfM9qSXaXkXuLO6Z4M2pSdXdFB19OVfzRmfLg9/jvC4qoZfADw+nbvB0W1o7h5G4QSx3IoHahmQSZEIDKH1p8d7ck7arRhnfE8Edxm4pr+1xkpvi/5f+GzPyuc/UojPh0jhjswTJ6onLfopLUPalotI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709156993; c=relaxed/simple; bh=7gqiz7x0UycIlkK9iH6yBO8Kv9c1/GvxVXPZGKKCqRg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=YK78cIfpeVt3xOVDDsWKUHLi/1bhW9uGdxYyfZ6pxQT9woJKi15tAzB6xQ662ck2qDQd/KPpcqhkCBSFsqjsykUpv6BUsO5Z8jaw1jsoKWvHKb17pQRza7Q6tlFxvNU1RZVdHnZ5h1OIiwOQdpXh4PYYkwzoQ+gJKh/L2mhx5HM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709156991; 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=cwzip4a+QoKw4E327aVvelCiGFwLWwIosXbzVqJ9x5Q=; b=MjzQ/r7BaFHHR174MnIrsFLW/IxDIkG9UJk2R1H0Lp4gP3lq9cm+PuCFfhBEtKJi7RmSpq Hdpihcm8cDn0x+bHPjtmUjcgcCZjyQahTe5hZpmEzPAeN9aDLkvfWNVKi06Nun5u94fPgY pPBK/9L2KiF9zJPKN7nA1Hwpg95J5t0= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-s1v2Q6ZjN_qntdWafI-5oQ-1; Wed, 28 Feb 2024 16:49:49 -0500 X-MC-Unique: s1v2Q6ZjN_qntdWafI-5oQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-78319f64126so30290585a.3 for ; Wed, 28 Feb 2024 13:49:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709156989; x=1709761789; 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=cwzip4a+QoKw4E327aVvelCiGFwLWwIosXbzVqJ9x5Q=; b=EvFTXiyOvKUwUDEoI0xqZiRA4zrAFMzr1XOFVD9hCZx1SivAoiB73JgmkpIM5cuzwl krMmc4fhbCZ+tAEoARiEBLHuVBoWKi6AL54/u26YAi/bOnjsivsESWvzJIpvQwGTos+P csWpuNLzGCnXn7edsTy3FTZ7pNH+9ko0e0P+RgiZ3W1p5m7FwNx0KPLYMdgUV0nLAswf b8gVLsjoa1aDeUbxrAlHuBSxHQJGFUdMQTPyhPx/mWTYOq1vecFAnY0apAtigOBNv+cm S8eCgPC/1gkG5vcMT2ObhaOtt0Viu8DKRUlzjmbtVYbiQnvGun4T0wAFExbc1mrLd/YP FxIg== X-Gm-Message-State: AOJu0Ywu27yoez2sIMDTQyloo4O3XWCvKXudEtmc9+aUYm4T1pyVfGfr XlK8NU6yegGY8jc37hMpdz6qMJuwBnKuFnXdMXxwqm/8jxUh1We+JcPM+4jn4VLf2PNsuGFEAj/ 7GkOXIvmV6ONk5ocmfWFHYrv5YCvEusQroUZGvEd6MoZGG9DJ3pkZjN0= X-Received: by 2002:a05:620a:24cb:b0:787:f42e:99f with SMTP id m11-20020a05620a24cb00b00787f42e099fmr401489qkn.12.1709156989063; Wed, 28 Feb 2024 13:49:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKk2YfTH35xRwAh6xr4EIXdkSFqkWkt+IX+hRjJHuElNgJQFWZ/lD6l0Wnd/u8Cmk2heV20Q== X-Received: by 2002:a05:620a:24cb:b0:787:f42e:99f with SMTP id m11-20020a05620a24cb00b00787f42e099fmr401479qkn.12.1709156988797; Wed, 28 Feb 2024 13:49:48 -0800 (PST) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id m20-20020a05620a221400b00787ec0fc392sm37753qkh.21.2024.02.28.13.49.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Feb 2024 13:49:48 -0800 (PST) Message-ID: <63545bd7-2efe-4839-99c2-995bf4bf81a5@redhat.com> Date: Wed, 28 Feb 2024 16:49:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Fix explicit instantiation of const variable templates after earlier implicit instantation [PR113976] To: Patrick Palka , Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <5f8065e9-65c2-64a1-3a8d-5437c334e059@idea> From: Jason Merrill In-Reply-To: <5f8065e9-65c2-64a1-3a8d-5437c334e059@idea> 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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 2/26/24 12:10, Patrick Palka wrote: > On Tue, 20 Feb 2024, Jakub Jelinek wrote: > >> Hi! >> >> Already previously instantiated const variable templates had >> cp_apply_type_quals_to_decl called when they were instantiated, >> but if they need runtime initialization, their TREE_READONLY flag >> has been subsequently cleared. >> Explicit variable template instantiation calls grokdeclarator which >> calls cp_apply_type_quals_to_decl on them again, setting TREE_READONLY >> flag again, but nothing clears it afterwards, so we emit such >> instantiations into rodata sections and segfault when the dynamic >> initialization attempts to initialize them. >> >> The following patch fixes that by not calling cp_apply_type_quals_to_decl >> on already instantiated variable declarations. > > LGTM, this seems like the safest approach for backporting. Note > we can't check DECL_EXPLICIT_INSTANTIATION at this point because > that doesn't get set until later from do_decl_instantiation. Agreed, OK.