From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by sourceware.org (Postfix) with ESMTPS id ABC01385803A for ; Wed, 10 Nov 2021 22:07:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ABC01385803A Received: by mail-pj1-x102c.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so2837456pju.3 for ; Wed, 10 Nov 2021 14:07:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jH5LNdEHsR8F9kRMsLqMZfneRzG+tjEK2rCNQTMNAZI=; b=eiLF2cl2g/pGwyFrifhRKhjxDEz4Ejajoc5BRkEg9HM6uN9eYP1Notx/zjl6dma8T5 dudmoAIuX7DYJEPB4v3miIaZ5CnWhew14F/Ow5Q3zVH1sCXh+hWeySsjSFHBl81MXZLb feDDdKrB39aRrrGXCGxtaFstQfGI9ugmRyZxohgYoHFBoy1kOT1Z2YSVIZZKuTXa5Ds+ trzXBkweIxS+l5cpuRbKeBOuh1RcUBW38QaZDKYLZdMCinqL5HVeB+GtP1ojSr8GvLb1 iaKnv4uZzcEiX7CvIP/1lsp5hZ2D31NCvLP1BoRwgXql0mGMAZvUruVysC3p6IT4Sqvq rmJg== X-Gm-Message-State: AOAM531khNbMcEMMfFXDlb2ywN2eW26sN55NFhkQmdribEnEasnjkdak fh1trXBEwfSwFTuk3RHuzPihCxjTj8o= X-Google-Smtp-Source: ABdhPJyTIH1D3EXe+JTSevz5ZsKjozV6v09H643bV5O9eD8mo3D0MLJp0pZjim7vQUTjxVioQ894Vw== X-Received: by 2002:a17:90b:33c2:: with SMTP id lk2mr21102267pjb.19.1636582068620; Wed, 10 Nov 2021 14:07:48 -0800 (PST) Received: from [192.168.0.41] (184-96-250-76.hlrn.qwest.net. [184.96.250.76]) by smtp.gmail.com with ESMTPSA id g9sm594016pfc.182.2021.11.10.14.07.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Nov 2021 14:07:48 -0800 (PST) Subject: Re: [PATCH] testsuite/102690 - XFAIL g++.dg/warn/Warray-bounds-16.C To: Richard Biener , gcc-patches@gcc.gnu.org References: From: Martin Sebor Message-ID: <73c2191f-5cc8-47d9-4167-63eb29b4d613@gmail.com> Date: Wed, 10 Nov 2021 15:07:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2021 22:07:51 -0000 On 11/10/21 3:09 AM, Richard Biener via Gcc-patches wrote: > This XFAILs the bogus diagnostic test and rectifies the expectation > on the optimization. > > Tested on x86_64-unknown-linux-gnu, pushed. > > 2021-11-10 Richard Biener > > PR testsuite/102690 > * g++.dg/warn/Warray-bounds-16.C: XFAIL diagnostic part > and optimization. > --- > gcc/testsuite/g++.dg/warn/Warray-bounds-16.C | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C > index 17b4d0d194e..89cbadb91c7 100644 > --- a/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C > +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-16.C > @@ -19,11 +19,11 @@ struct S > p = (int*) new unsigned char [sizeof (int) * m]; > > for (int i = 0; i < m; i++) > - new (p + i) int (); > + new (p + i) int (); /* { dg-bogus "bounds" "pr102690" { xfail *-*-* } } */ > } > }; > > S a (0); > > -/* Verify the loop has been eliminated. > - { dg-final { scan-tree-dump-not "goto" "optimized" } } */ > +/* The loop cannot be eliminated since the global 'new' can change 'm'. */ I don't understand this comment. Can you please explain how the global operator new (i.e., the one outside the loop below) can change the member of the class whose ctor calls the new? The member, or more precisely the enclosing object, doesn't yet exist at the time the global new is called because its ctor hasn't finished, so nothing outside the ctor can access it. A pointer to the S under construction can be used (and could be accessed by a replacement new) but it cannot be dereferenced to access its members because the object it points to doesn't exist until after the ctor completes. I copy the test below: inline void* operator new (__SIZE_TYPE__, void * v) { return v; } struct S { int* p; int m; S (int i) { m = i; p = (int*) new unsigned char [sizeof (int) * m]; for (int i = 0; i < m; i++) new (p + i) int (); /* { dg-bogus "bounds" "pr102690" { xfail *-*-* } } */ } }; S a (0); Thanks Martin