From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 42804385842B for ; Fri, 23 Feb 2024 09:13:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42804385842B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 42804385842B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708679627; cv=none; b=ifnIBETEzpZSIzD4tyAlUzzM2k+gXVu2weIaTNkqawjlqMf/v992eS+jqiMPH5EKP3SIZmiTgpZNmm9DXynKC3Sl08JaLvkJAehHsGHi7eG5ZEl3HMYyYQ/B058i6Nlxwmlg2J61iGWulCWnrlNYb0Db50TEyWnQtDc7RTrWLKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708679627; c=relaxed/simple; bh=M8SDq+DsKwVWnoFHQvA+yDZgxXV253YTyE2rTLU2yio=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=tnEcvdbtiniCpHpSXd0EvYXsHtS5uNU7YauCJNrX6UmsFLgT87TQq/ANIO64c/WajErc5JDnV2olgmpALFc1ArWETLs+MDEajrmQ/MKBNfhG+38tmE16zHSmVwAGlhh2L29FhZ2fgZXkoaWN8bU+2TGwR02L6UG1/wxDlZr1tu0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a3e552eff09so59709666b.3 for ; Fri, 23 Feb 2024 01:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708679621; x=1709284421; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TDF8PjNuljhCmKhvzON7lLTTJBYx+W2b6JfpHMJLr64=; b=VSjPxTbuXI1Zu+pchvUCwU+z8s+WtjFQ8IImlWVVIU83BSorHVMlhdNYu2sO5Dv878 t8PRHWr5yeGJ+A0Ker8WsvE/N6PcZailbnQWK0irA4Mnmm6J0VQZJkmflwkOGJ+tQC0i +4y6ti/D+Ts/kK0luyJgMLlXpj9rvSej7+emVRzyk0YMoCNcyQ6OF4KF9MQmJ0kA/Yak qxS46TOcVfQnq2vlTKkjCKK2SCUg89z5FWlK3aGdP82tZUCUHFf1eGd+CkUkhW/I3xtJ U+S5RHxjvYLEwxLtNiMnGyxHZGgaVNCxHgReTk5Dy3oG6UrGzm0sbXZVF7eAukPaaHus xSwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708679621; x=1709284421; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TDF8PjNuljhCmKhvzON7lLTTJBYx+W2b6JfpHMJLr64=; b=HA/kV+Jpv17SxxuPczo7VPXm38qQ4P8GOLM4R2y9oellHS4dovGGNVrwg5MEXicUxy 4Sjx6ukM0ETJn3Ov8+43dCmYh3FqnGHXCgVe4mX73wXbJ8t/jyGNmaUhz09QAdYKrgVx jOvwF9AoSqC1xmi2fTNFoiUFy4/BpysHrOwA20ztJD0kHcB8bpTBd6RVYIfAX6X3jcMy 7mMuf5RUf5n9YJS4rzwXBKyDeyhSL1DZ34bK3OM3JjOQXZ+atJQxg33fxQr9F8juiQrz fcwN0GG8CaMhSDwlbG8AUYNyL4N26EFwLtM1IMhNPORYc5spXj3H2F3mAIk2EHWp1go0 YouA== X-Forwarded-Encrypted: i=1; AJvYcCVCF/Dayqwzdd8tQOR7KHSuv8GNc90pKRL7cXR3NXjI5jgmjJ7P4zM0Bqy7UKTrPr1GMbo7lLIne26GpBODND98NNHIVhLVqg== X-Gm-Message-State: AOJu0Yw8nsztWn+rl4VeBDv1sn231Jy7VBZESvAVzsW6W3B0502iJChP LBKmQ1kqWpHiW3UBhOxMISPLT7FMDlPlh9s4vAC0CWU3POZd83OXDgvYq/AaWVDeMK2L5DE35Ya YqQuH/y+ijDjTXJWB5qJrVlDY5FS1r+ze5aFDPg== X-Google-Smtp-Source: AGHT+IGOdx04JwAAlNIHxnby3HONxim/bDkZuHKVmr7k2fvveiOBy5VN4RjZ3VJ7x2oQiQWTA4B0fGRteXc1sL7gZD0= X-Received: by 2002:a17:906:b898:b0:a3f:d1f5:c954 with SMTP id hb24-20020a170906b89800b00a3fd1f5c954mr488823ejb.20.1708679621050; Fri, 23 Feb 2024 01:13:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Christophe Lyon Date: Fri, 23 Feb 2024 10:13:35 +0100 Message-ID: Subject: Re: [PATCH] c++: Fix ICE due to folding a call to constructor on cdtor_returns_this arches (aka arm32) [PR113083] To: Jakub Jelinek Cc: Jason Merrill , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Fri, 23 Feb 2024 at 09:42, Jakub Jelinek wrote: > > Hi! > > When targetm.cxx.cdtor_returns_this () (aka on arm32 TARGET_AAPCS_BASED) > constructor is supposed to return this pointer, but when we cp_fold such > a call, we don't take that into account and just INIT_EXPR the object, > so we can later ICE during gimplification, because the expression doesn't > have the right type. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux and > tested with a cross to armv7-linux-gnueabi on the testcase, but > unfortunately there are no 32-bit arm boxes in cfarm and arm32 is gone from > Fedora for quite some time as well, so I have no easy way to test this. > Christophe, do you think you could test this? Thanks. Hi Jakub, Sadly our precommit CI could not apply your patch automatically (as you can see in patchwork). I'll test your patch manually. Thanks, Christophe > > 2024-02-23 Jakub Jelinek > > PR c++/113083 > * cp-gimplify.cc (cp_fold): For targetm.cxx.cdtor_returns_this () > wrap r into a COMPOUND_EXPR and return folded CALL_EXPR_ARG (x, 0). > > * g++.dg/cpp0x/constexpr-113083.C: New test. > > --- gcc/cp/cp-gimplify.cc.jj 2024-02-22 21:45:09.663430066 +0100 > +++ gcc/cp/cp-gimplify.cc 2024-02-22 22:30:23.481428242 +0100 > @@ -3412,9 +3412,15 @@ cp_fold (tree x, fold_flags_t flags) > if (DECL_CONSTRUCTOR_P (callee)) > { > loc = EXPR_LOCATION (x); > - tree s = build_fold_indirect_ref_loc (loc, > - CALL_EXPR_ARG (x, 0)); > + tree a = CALL_EXPR_ARG (x, 0); > + bool return_this = targetm.cxx.cdtor_returns_this (); > + if (return_this) > + a = cp_save_expr (a); > + tree s = build_fold_indirect_ref_loc (loc, a); > r = cp_build_init_expr (s, r); > + if (return_this) > + r = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (x), r, > + fold_convert_loc (loc, TREE_TYPE (x), a)); > } > x = r; > break; > --- gcc/testsuite/g++.dg/cpp0x/constexpr-113083.C.jj 2024-01-13 00:05:00.077372302 +0100 > +++ gcc/testsuite/g++.dg/cpp0x/constexpr-113083.C 2024-02-22 22:20:20.622618992 +0100 > @@ -0,0 +1,16 @@ > +// PR c++/113083 > +// { dg-do compile { target c++11 } } > +// { dg-options "-Os" } > + > +struct A { constexpr A (); }; > + > +void > +foo () > +{ > + A b; > +} > + > +constexpr > +A::A () > +{ > +} > > Jakub >