Deutsch   English   Français   Italiano  
<vqrm0i$2frof$7@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!eternal-september.org!.POSTED!not-for-mail
From: Richard Heathfield <rjh@cpax.org.uk>
Newsgroups: comp.theory
Subject: Re: Every sufficiently competent C programmer knows
Date: Wed, 12 Mar 2025 10:00:50 +0000
Organization: Fix this later
Lines: 26
Message-ID: <vqrm0i$2frof$7@dont-email.me>
References: <vqntaq$1jut5$1@dont-email.me> <vqp388$1tvqa$1@dont-email.me>
 <vqpdv9$202b2$2@dont-email.me> <vqperb$20c9k$2@dont-email.me>
 <E6mcnWv3nMa66036nZ2dnZfqnPWdnZ2d@brightview.co.uk>
 <vqpv2u$23vhr$1@dont-email.me> <vqrlar$2ht6c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Mar 2025 11:00:50 +0100 (CET)
Injection-Info: dont-email.me; posting-host="1e46a42d02300691bd0ac693a83620d5";
	logging-data="2617103"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+n0F6coMH72huys51BpL+N/caCEQx+nwHNTkRH/yi7VQ=="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dCInJhbzGqYiMM8Kbmh0W6Bi5wU=
Content-Language: en-GB
In-Reply-To: <vqrlar$2ht6c$1@dont-email.me>
Bytes: 1905

On 12/03/2025 09:49, Mikko wrote:
> On 2025-03-11 18:23:24 +0000, Richard Heathfield said:
> 
>> int rhc(unsigned int i)
>> {
>>    typedef int(*pf)(unsigned int);
>>    pf arr[3] = {rha, rhb, rhc};
>>    return arr[i % 3];
> 
> The return instruction has wrong type.

Good spot, but no, it's fine. The bug is elsewhere. That line 
should read:

return arr[i % 3](i);

arr is of type int(*)(unsigned int)[3]
arr[i % 3] is of type int(*)(unsigned int)
arr[i % 3](i) is a function call returning int

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within