Fwd: Re: free() and implicit conversion to a function pointer (was: Use of initialized variable in strtod.c)

Eric Blake eblake@redhat.com
Mon Mar 20 18:45:00 GMT 2017

On 03/17/2017 04:04 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).

Then again, not all newlib targets aim for POSIX compliance, and it is
entirely feasible that someone is trying to use newlib to achieve C99
compliance without caring about additional POSIX requirements.

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20170320/9d1d9759/attachment.sig>

More information about the Newlib mailing list