Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Safety of casting from 'long' to 'int'
Date: Mon, 01 Jun 2026 15:20:42 -0700
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <86v7c1dhs5.fsf@linuxsc.com>
References: <10su8cn$am9i$1@dont-email.me> <10tl03i$1l93l$8@dont-email.me> <10tl7qb$fo0$1@reader1.panix.com> <86ecjkshx0.fsf@linuxsc.com> <10tntpi$jbt$1@reader1.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Mon, 01 Jun 2026 22:20:45 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="2648922"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QYm4UC6mmzSMGwf2PKRRchf6GKyG9w3g="; posting-host="931249e2bc9d85e6e23258ad4c33c174"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:IdIiL6bpnDk0wj/fBpC4slx9TkE= sha1:mwq9LDrqd7I7PYc7miPuX3QhXLs= sha256:3n+ASyETwsbGZypagswWP9QeotyVZ+9diIF2r9t0mho= sha1:GiK8CiG93SjAsCE2pztHLnT5jLA=
Xref: csiph.com comp.lang.c:399597
cross@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <86ecjkshx0.fsf@linuxsc.com>,
> Tim Rentsch wrote:
>
>> cross@spitfire.i.gajendra.net (Dan Cross) writes:
>>
>>> Examples of statically typed languages include SML, Haskell,
>>> Rust, etc. Those are also all strongly typed.
>>
>> Rust is not generally considered to be strongly typed.
>
> By whom?
>
>> Rust has
>> raw pointers and unsafe functions, both of which (can) violate
>> type safety.
>
> That is orthogonal to whether or not it the language is strongly
> typed.
>
> Perhaps you meant memory safety? In which case it is worth
> stating that the langauge only guarantees memory safety for the
> safe subset.
>
> Dereferencing a raw pointer, including for assignment through
> that pointer, can only be done in an `unsafe` block. Unsafe
> functions have no _a priori_ bearing on memory (let alone type)
> safety; they only impose the requirement that they must be
> called from from an `unsafe` block.
>
> Using the `unsafe` language requires using an `unsafe` block,
> even in a function marked `unsafe` (admitted, this did change
> from earlier editions of the language).
There is something I would say here, but I am reminded that my
remarks would be off topic, so I simply going to stop. My
apologies for my earlier off-topic post upthread.