From dev-return-7099-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Thu Mar 20 18:29:07 2008 Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 56758 invoked from network); 20 Mar 2008 18:29:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2008 18:29:07 -0000 Received: (qmail 93347 invoked by uid 500); 20 Mar 2008 18:29:04 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 93323 invoked by uid 500); 20 Mar 2008 18:29:04 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 93314 invoked by uid 99); 20 Mar 2008 18:29:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 11:29:04 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 18:28:26 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m2KISaVV011281 for ; Thu, 20 Mar 2008 18:28:36 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [TESTCASE] STDCXX-750 [HP aCC 6.16] Potential null pointer dereference in aliases.cpp Date: Thu, 20 Mar 2008 12:29:10 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [TESTCASE] STDCXX-750 [HP aCC 6.16] Potential null pointer dereference in aliases.cpp Thread-Index: AciKtN5rJEIPHoTJQYSryaeTFegbzwAAYP1w References: <47E2A684.3000708@roguewave.com> From: "Scott Zhong" To: X-Virus-Checked: Checked by ClamAV on apache.org Martin, would you suggest that there should be a check after malloc and throw bad_alloc? > -----Original Message----- > From: Martin Sebor [mailto:msebor@gmail.com] On Behalf Of Martin Sebor > Sent: Thursday, March 20, 2008 12:02 PM > To: dev@stdcxx.apache.org > Subject: Re: [TESTCASE] STDCXX-750 [HP aCC 6.16] Potential null pointer > dereference in aliases.cpp >=20 > I was going to say this is the same bug as STDCXX-764: > http://issues.apache.org/jira/browse/STDCXX-764 > but after looking at it more closely I believe the compiler > is correct in this case because malloc() returns 0 when it > fails to allocate memory. The warning could be clearer about > it. >=20 > Martin >=20 > Scott Zhong wrote: > > cat /build/scottz/t2.cpp && aCC -V && aCC -c +w /build/scottz/t2.cpp > > #include > > > > int main() > > { > > static char * test =3D 0; > > if (!test) { > > test =3D (char *)std::malloc (12345); > > *test =3D '\0'; > > } > > > > return 0; > > } > > aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007] > > "/build/scottz/t2.cpp", line 8, procedure main: warning #20200-D: > > Potential > > null pointer dereference through test is detected (null > > definition:/build/scottz/t2.cpp, line 7) > > > > this test case shows that the warning is bogus because the pointer > > "test" is pointing to a valid location in memory after std::malloc is > > performed. > >