This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: free() and implicit conversion to a function pointer


On Mar 17 00:49, Hans-Bernhard Bröker wrote:
> 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.

Wasn't that supposed to go to the newlib list where this has been
discussed originally?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]