Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <uu8s6n$v2o8$2@dont-email.me>
Deutsch   English   Français   Italiano  
<uu8s6n$v2o8$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Casting the return value of ...
Date: Sat, 30 Mar 2024 11:14:32 +0000
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uu8s6n$v2o8$2@dont-email.me>
References: <uu416t$33u55$1@news.xmission.com>
 <20240328105203.773@kylheku.com> <87frwatadu.fsf@nosuchdomain.example.com>
 <uu4k1c$3pq71$1@dont-email.me> <uu6dtk$a076$1@dont-email.me>
 <uu6fss$agvi$1@dont-email.me> <86plvchxpn.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 30 Mar 2024 11:14:32 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2a39a4f275d14f8fd4fa1a15ff029e85";
	logging-data="1018632"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18dvicFwgptR+iWH4CKpY2Y"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hTpjVBVQcItwIFnUrC82bHFuhwk=
Content-Language: en-GB
In-Reply-To: <86plvchxpn.fsf@linuxsc.com>
Bytes: 2761

On 30/03/2024 09:32, Tim Rentsch wrote:
> bart <bc@freeuk.com> writes:

>> I was aware of the double conversion but KT used 'a cast' so I
>> wondered if there was a single cast that could be used.
> 
> There is not, if it's important that it work reliably across
> different compilers and different platforms.
> 
>> It is odd however that function and object pointers can be
>> considered so different that even an explicit conversion
>> between them is deemed to be meaningless.
> 
> Function pointers and object pointers don't have to be the same
> size, or use the same form of representation.  The C standard
> allows implementations where code and data live in completely
> separate memories.  In such cases there is no sensible way to
> convert between the two kinds of pointers, because the two kinds
> of addresses have no relationship to each other.

Suppose a object pointer is 32 bits, and a function pointer is a 32-byte 
descriptor.

An implementation could choose to present a function pointer as a 32-bit 
object pointer, which points to the full 32-byte descriptor in data memory.

The simplest way of doing that is to have, for each function (or each 
one whose address is taken), a fixed corresponding descriptor in data 
memory. So here function and object pointers can be exactly the same 
size, and can both refer to data memory, as far as the programmer is 
concerned.

Dereferencing such a function pointer, to call the function, will 
involve an extra bit of indirection. It would need something extra 
anyway to deal with those 32 bytes.