public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: free() and implicit conversion to a function pointer
Date: Mon, 20 Mar 2017 18:43:00 -0000	[thread overview]
Message-ID: <d9b1d7d9-a5bc-13fa-35e7-3b289edb349b@redhat.com> (raw)
In-Reply-To: <f76885f4-f99f-dc50-2a19-cb892a62db7e@t-online.de>


[-- Attachment #1.1: Type: text/plain, Size: 886 bytes --]

On 03/16/2017 02:24 PM, Hans-Bernhard Bröker wrote:
> 
> The reason this is wrong is that C by design treats data and functions
> as living in separate realms, i.e. its virtual machine has a Harvard
> architecture.  One of the consequences of this is that pointers to
> functions and pointers to data are incommensurable, i.e. any and all
> conversions or comparisons across this divide are wrong.  (void *) are
> compatible to all data pointers, but not to function pointers.

That's true of strict C99, but not true of POSIX (which adds the
additional requirements above-and-beyond C99 that NULL be equivalent to
((void*)0) and that any function pointer can be converted to void* and
back without loss of information, in part because of dlsym() and friends).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

      parent reply	other threads:[~2017-03-20 18:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c5af0608-17c4-2270-dbba-c3b704c9226e@t-online.de>
2017-03-16 19:25 ` free() and implicit conversion to a function pointer (was: Use of initialized variable in strtod.c) Hans-Bernhard Bröker
2017-03-16 21:46   ` free() and implicit conversion to a function pointer L A Walsh
2017-03-16 23:49     ` Hans-Bernhard Bröker
2017-03-17  8:30       ` Corinna Vinschen
2017-03-17 21:01         ` Hans-Bernhard Bröker
2017-03-20 18:43   ` Eric Blake [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9b1d7d9-a5bc-13fa-35e7-3b289edb349b@redhat.com \
    --to=eblake@redhat.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).