From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38C943945C1D; Tue, 20 Oct 2020 15:30:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38C943945C1D From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/90629] Support for -Wmismatched-new-delete Date: Tue, 20 Oct 2020 15:30:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2020 15:30:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D90629 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot g= nu.org --- Comment #3 from Martin Sebor --- With the patch I'm testing GCC reports the following for the test case in comment #2: 90629-c2.C: In function =E2=80=98void f()=E2=80=99: 90629-c2.C:8:16: warning: =E2=80=98void operator delete(void*, long unsigne= d int)=E2=80=99 called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 8 | delete p; | ^ 90629-c2.C:7:33: note: returned from a call to =E2=80=98void* operator new = [](long unsigned int)=E2=80=99 7 | char * p =3D new char [ 10]; | ^ 90629-c2.C:11:19: warning: =E2=80=98void operator delete [](void*)=E2=80=99= called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 11 | delete [] p2; | ^~ 90629-c2.C:10:25: note: returned from a call to =E2=80=98void* operator new= (long unsigned int)=E2=80=99 10 | char * p2 =3D new char; | ^~~~ 90629-c2.C:17:19: warning: =E2=80=98void operator delete [](void*)=E2=80=99= called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete] 17 | delete [] q2; | ^~ 90629-c2.C:16:36: note: returned from a call to =E2=80=98void* malloc(size_= t)=E2=80=99 16 | char * q2 =3D (char *) malloc( 10); | ~~~~~~^~~~~ The call to free(q) isn't diagnosed in the simple test case because it's eliminated by the cddce pass along with the new expression.=