Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 44187 invoked from network); 20 Mar 2008 20:55:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2008 20:55:09 -0000 Received: (qmail 98159 invoked by uid 500); 20 Mar 2008 20:55:07 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 98145 invoked by uid 500); 20 Mar 2008 20:55:06 -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 98136 invoked by uid 99); 20 Mar 2008 20:55:06 -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 13:55:06 -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: domain of msebor@gmail.com designates 64.233.170.191 as permitted sender) Received: from [64.233.170.191] (HELO rn-out-0910.google.com) (64.233.170.191) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Mar 2008 20:54:27 +0000 Received: by rn-out-0910.google.com with SMTP id s28so1061231rnb.13 for ; Thu, 20 Mar 2008 13:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=o+UpWZeT5xOB/PeOPO7CQSnjf+a3JzOKMj4b5ReIwY0=; b=QCxtOrfqdOpo8ZbVnQCik0LmaYuIJQ9va1CxaOdQjmuc5BCT3AfIUtRqihWX5E9oWJfO1dE1riiUVr/AFbmTe5eVTNxE1yHclXccirAW/4M7nOwx13d6W7JVOp9jfbQRvj+TuPKLVZ+7hHgYcjVpt9FY9VYojZaVFDLLh1ygGUw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=UNi8+xQ084zk8qywyiY43kGV8WK84ZIElWPOd3kzuazgNKFUkpSyK2n6DSkmspQoZBAnqA7imp6oIJLVZkn8I3+cvkDZmcj387kOHF9HVEeObcwJR1E1XmK2rNfPfe2SNrlXkFnRRH7X9S4nm4ZYSzkzLg7VDCTmcJBkAUjiPzY= Received: by 10.142.52.9 with SMTP id z9mr1825067wfz.237.1206046476967; Thu, 20 Mar 2008 13:54:36 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id 27sm4433520wff.8.2008.03.20.13.54.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 20 Mar 2008 13:54:36 -0700 (PDT) Message-ID: <47E2CF0A.6000305@roguewave.com> Date: Thu, 20 Mar 2008 14:54:34 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: [TESTCASE] STDCXX-750 [HP aCC 6.16] Potential null pointer dereference in aliases.cpp References: <47E2A684.3000708@roguewave.com> <47E2CABE.4060009@roguewave.com> In-Reply-To: <47E2CABE.4060009@roguewave.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org FYI: This was simple enough that I made the change myself: http://svn.apache.org/viewvc?rev=639452&view=rev Martin Martin Sebor wrote: > Scott Zhong wrote: >> Martin, would you suggest that there should be a check after malloc and >> throw bad_alloc? > > I think we should just use the new expression instead of calling > malloc. That way we don't need to check. Unless we call malloc() > in the rest of the program for some reason. > > Martin > >> >>> -----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 >>> >>> 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. >>> >>> Martin >>> >>> Scott Zhong wrote: >>>> cat /build/scottz/t2.cpp && aCC -V && aCC -c +w >> /build/scottz/t2.cpp >>>> #include >>>> >>>> int main() >>>> { >>>> static char * test = 0; >>>> if (!test) { >>>> test = (char *)std::malloc (12345); >>>> *test = '\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. >>>> >> >> > >