From -972165949385868297
X-Google-Thread: 7894ca11fe,9498f84f2fe77780,start
X-Google-Attributes: gid7894ca11fe,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 05 Sep 2009 22:30:01 -0500
Return-Path: <cppmods@ruralroute.cs.rpi.edu>
To: (Usenet)
From: "cdm.henderson@googlemail.com" <cdm.henderson@googlemail.com>
Newsgroups: comp.std.c++
Subject: delete multiple pointers
Organization: http://groups.google.com
Sender: cppmods@cs.rpi.edu
Approved: stephen.clamage@sun.com
Message-ID: <5abb2eee-8508-4309-b697-1958e225c7ad@o10g2000yqa.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
X-Original-Date: Sat, 5 Sep 2009 10:39:51 -0700 (PDT)
X-Submission-Address: std-c++@netlab.cs.rpi.edu
Date: Sat,  5 Sep 2009 22:26:15 CST
Lines: 28
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-fiO9GzSZm41+Bwc3PFXXvAW9pyYZtGj+DiL2V3DAIpHF9OVO7au9e/Jy3ZVtoPp+uT4r5mXoCS7PQol!BMrG8YqYZ/kF7TcH+rrVpZWxCgqNz2Uec/X8gyXpMkGh+iKJji7lx0Kend7yIg8LC9f/tW9SgdtV!tCD6eTkfm5niw3618S7p2QGYC8s=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.39
Xref: g2news2.google.com comp.std.c++:1354

As I understand the standard, the following code will not perform as
the developer expects and free memory of p1 & p2. MSVC8 confirms this
and leaks 34bytes at p2. I do not get any compilation warnings, even
at Level 4 (max warnings).

int main(int, char**)
{
     char *p1 = new char[23];
     char *p2 = new char[34];

     delete[] p1,p2;
     return 0;
}

I assume then, that the comma operator here is seen as the compiler as
separating two statements; "delete[] p1" and "p2", and that "p2" as
statement does nothing but is not an error. Is my understanding of
this correct?

Thanks
-- Craig

-- 
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



