[Info-vax] C et al (was: Re: Rust as a HS language, was: Re: Quiet?)
Arne Vajhøj
arne at vajhoej.dk
Mon Apr 11 19:35:53 EDT 2022
On 4/11/2022 9:14 AM, Simon Clubley wrote:
> On 2022-04-10, Stephen Hoffman <seaohveh at hoffmanlabs.invalid> wrote:
>> On 2022-04-10 02:29:53 +0000, Stephen Hoffman said:
>>> My usual pointer to just what volatile provides, and doesn't provide:
>>>
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1152r0.html
>>
>> For those that believe there is but one write with volatile, there's
>> one write per byte yes, but there can be multiple and arbitrary-ordered
>> writes involved within that operation.
>
> Any compiler doing anything as brain-dead as that would instantly be
> dropped and if it was an open-source compiler, would instantly be
> forked, XFree86 style, and the brain-dead additions removed.
If we look at the language standard, then ISO C has a lot of
undefined and implementation specific behavior. There are lot
of C code but not that much which is guaranteed to work by ISO C
standard.
"C deemed not brain-dead by Simon" is a very unofficial standard
that is not so relevant.
The practical impact may not be so big though.
I suspect that your use case may be typical for such code:
# Reasoning: the most common use of volatile I have in my code is
# for reading and writing to device registers.
You just need to know that the compiler you use will
do what you expect. You do not care if some compiler
somewhere else does not, because such code would
need to be rewritten anyway if ported read as
reimplemented for that platform.
C is more portable than assembler, but it is not that easy
to write 100% portable code in C. But then like above: if
100% portability is a requirement, then C is most likely not
the right choice of language!
Arne
More information about the Info-vax
mailing list