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 connectionsPath: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown
Newsgroups: comp.lang.c
Subject: Re: how cast works?
Date: Fri, 9 Aug 2024 19:12:47 +0200
Organization: A noiseless patient Spider
Lines: 59
Message-ID:
References:
<87ttfu94yv.fsf@nosuchdomain.example.com>
<87bk228uzg.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 09 Aug 2024 19:12:48 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="20dc90042b48f6417a3734e9d0abbff5";
logging-data="869434"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9CdgvboJvml6iybexD9843XqudWQMvxc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:sp5pCY2tQwESWY8f26KgDI3/kfg=
Content-Language: en-GB, nb-NO
In-Reply-To:
Bytes: 3080
On 09/08/2024 12:04, Bart wrote:
> On 09/08/2024 00:17, Keith Thompson wrote:
>> Bart writes:
>> [...]
>>> Take:
>>>
>>> int a; double x;
>>>
>>> x = (double)a;
>>>
>>> The cast is implicit here but I've written it out to make it clear.
>>
>> [...]
>>
>> The *conversion* could be done implicitly, but you've used a cast (i.e.,
>> an explicit conversion) to make it clear.
>>
>> There is no such thing as an "implicit cast" in C.
>>
>
> Suppose I write this code:
>
> x = a; // implicit 'conversion'
> x = (double)a; // explicit 'conversion'
>
>
> My compiler produces these two bits of AST for the RHS of both expressions:
>
> 1 00009 r64---|---2 convert: sfloat_c i32 => r64
> 1 00009 i32---|---|---1 name: t.main.a.1
>
> 1 00010 r64---|---2 convert: sfloat_c i32 => r64
> 1 00010 i32---|---|---1 name: t.main.a.1
>
> So whatever you call that `(double)` part of the second line, which is
> written explicitly, exactly the same thing is done internally (ie
> 'implicitly') to the first line. (The 09/10 are line numbers.)
>
You've written it yourself. Both are conversions - one is implicit, the
other is explicit.
> Since C likes to use the term 'cast' for such conversions, I don't see a
> problem with talking about implicit and explicit versions.
>
C does not "like" to use the term "cast" for anything other than cast
operations, as defined by the C standards. Implicit conversions are not
casts.
/You/ might like to call implicit conversions "casts", but you'd be
wrong to do so.
> It just seems to irk the pedantics here.
You mean, people who know what they are talking about rather than those
that make up stuff as they go along?