This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Fwd: Re: free() and implicit conversion to a function pointer (was: Use of initialized variable in strtod.c)
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Eric Blake <eblake at redhat dot com>
- Cc: newlib at sourceware dot org
- Date: Mon, 20 Mar 2017 14:57:39 -0400
- Subject: Re: Fwd: Re: free() and implicit conversion to a function pointer (was: Use of initialized variable in strtod.c)
- Authentication-results: sourceware.org; auth=none
- References: <f76885f4-f99f-dc50-2a19-cb892a62db7e@t-online.de> <5952177e-aff7-2653-8977-3295524fdb03@t-online.de> <f43b5494-513b-c5be-76a5-c7f81a69b9fa@redhat.com>
- Reply-to: noloader at gmail dot com
>> 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.
+1. When I test for compatibility or ST&E, then I will test some
stated features even if I don't use them. -std=c99, -ansi and
_XOPEN_SOURCE are usually easy enough to test.
(Newlib confounds me at the moment, though. I have not figured out an
easy way to test it).
Jeff