From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33403 invoked by alias); 16 Mar 2017 23:49:21 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 33383 invoked by uid 89); 16 Mar 2017 23:49:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*M:online, H*F:D*t-online.de, walsh, Walsh X-HELO: mailout01.t-online.de Received: from mailout01.t-online.de (HELO mailout01.t-online.de) (194.25.134.80) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Mar 2017 23:49:19 +0000 Received: from fwd02.aul.t-online.de (fwd02.aul.t-online.de [172.20.26.148]) by mailout01.t-online.de (Postfix) with SMTP id A76C1423DD42 for ; Fri, 17 Mar 2017 00:49:17 +0100 (CET) Received: from [192.168.2.28] (ZkD4e8ZcghzspYPr-rPZDVmkTrGmfb-HY6fa49VABEhPWJdd6pywmxETGAvGqYSw5y@[91.59.13.80]) by fwd02.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1cof8u-09UBc00; Fri, 17 Mar 2017 00:49:16 +0100 Subject: Re: free() and implicit conversion to a function pointer To: cygwin@cygwin.com References: <58CB07A8.9010401@tlinx.org> From: =?UTF-8?Q?Hans-Bernhard_Br=c3=b6ker?= Message-ID: <33519566-7f9a-ad78-6160-ccfa6465c279@t-online.de> Date: Thu, 16 Mar 2017 23:49:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <58CB07A8.9010401@tlinx.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00182.txt.bz2 Am 16.03.2017 um 22:46 schrieb L A Walsh: > Going by subj and talk below, this is a bit confusing... > > But it looks like you are testing 'free' for a value? Not really. The idea is to test free for _exixtence_. Which only makes sense in case of weak symbol support getting involved. In other situations, there could not possibly be a need for a run-time if() test, because surely the code could know at build time whether free() exists or not. > Isn't standard 'free' declared to take 1 arg and > return void? Yes. But since the code in question doesn't actually _call_ free, that's both irrelevant. > If you aren't talking standard 'free()', then > nevermind... We are talking standard free. More to the point, we're discussing newlib, the package that actually implements free() for cygwin. >> The only code that might actually be a slight bit better than the given >> >> if (! free) >> >> would be >> >> if (0 != free) >> >> The function designator `free' auto-decays into a function pointer, >> which is compared to a null pointer constant: 0. The ! operator does >> that same thing implicitly, but is fully equivalent to it. > --- > Free autodecays to a function pointer? In the use case at hand: yes, it does. > In what language? Standard C. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple