Re: incorrect use of 'pure' attribute

Arsen Arsenović <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
Bruno Haible <[email protected]> writes:

> Paul Eggert wrote:
>> > Storing the same value in the same location (of
>> > type 'int') is OK not only on those platforms where an 'int' access is atomic,
>> > but even on architectures (such as m68k) where it isn't.
>> 
>> This variable is 'long', not 'int'.
>
> Oops, right. But anyway, 'long' is the size of a machine word, and except
> on m68k, for aligned accesses, loads and stores of such words are atomic.

Please don't make assumptions like these when there are better
alternatives.

Such assumptions are sources of endless and hard-to-find bugs.

There's no reason to assume loads and stores of such words compile down
to the loads and stores in hardware of the same kind you're thinking of.

This is _only_ guaranteed if using atomic accesses (whether through
atomic/sync builtins or stdatomic or even inline 'asm').  If anything,
such reasoning should encourage you *to* use atomic accesses, not to
abstain from using them, as they lack bugs while likely compiling down
to exactly the same code.
-- 
Arsen Arsenović
signature.asc (application/pgp-signature, 288 B)
-----BEGIN PGP SIGNATURE-----

iKIEARYKAEoWIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCaniVWxsUgAAAAAAEAA5t
YW51MiwyLjUrMS4xMiwyLDIQHGFyc2VuQGFhcnNlbi5tZQAKCRBSwpQwHqLEk6s7
AQD89/zOWXQaUCXaMeaeyS11mm8DiMB2pQeTlHx5dyZycQD+JjfacISFbuGcugHk
Z9wuJq6YwlREvF7ciikOWg7AYgk=
=L6+0
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.